从您的Obc-C代码中,我认为您想为按钮设置图片,因此请尝试以下方式:
let playButton = UIButton(type: .Custom)if let image = UIImage(named: "play.png") { playButton.setImage(image, forState: .Normal)}
简而言之:
playButton.setImage(UIImage(named: "play.png"), forState: UIControlState.Normal)
对于Swift 3:
let playButton = UIButton(type: .custom)playButton.setImage(UIImage(named: "play.png"), for: .normal)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)