【发布时间】:2016-08-11 17:08:39
【问题描述】:
当 UIButton 被选中时,我遇到了问题。代码在 Swift 3 中:
let radioButton = UIButton(type: .system)
radioButton.frame = CGRect(x: 0, y: 0, width: 40, height: 40)
radioButton.setImage(UIImage(named: "buttonUnchecked"), for: .normal)
radioButton.setImage(UIImage(named: "buttonChecked"), for: .selected)
radioButton.setTitle("This is some text.", for: .normal)
radioButton.sizeToFit()
当被radioButton.isSelected = true选中时,不显示图片。
【问题讨论】:
-
您检查了图像
buttonChecked是否存在且没有错字? -
您是否在视图中添加了radioButton?