SwiftでUIButtonに画像を表示させる方法。
let imageButton = UIButton()
imageButton.setImage(UIImage(named:"sample")!, for: .normal)
self.view.addSubview(imageButton)
UIbuttonにsetImage
関数を割り当てるだけ。
リファレンスによるとsetImageでは以下の宣言がなされる。
func setImage(_ image: UIImage?,
for state: UIControl.State)
//image
//The image to use for the specified state.
//state
//The state that uses the specified image. The values are described in UIControl.State.
参考
Swiftのお役立ち情報