我正在尝试使用IBDesignable。但像往常一样它不起作用。
我的控制器代码:
@IBDesignable
class MainMenuViewController: UIViewController {
@IBOutlet weak var languagesButton: UIView!
@IBOutlet weak var keyboardSettingsButton: UIView!
@IBOutlet weak var aboutButton: UIView!
@IBOutlet weak var helpButton: UIView!
@IBInspectable var buttonsCornerRadius: CGFloat = 5 {
didSet {
languagesButton.layer.cornerRadius = buttonsCornerRadius
keyboardSettingsButton.layer.cornerRadius = buttonsCornerRadius
aboutButton.layer.cornerRadius = buttonsCornerRadius
helpButton.layer.cornerRadius = buttonsCornerRadius
}
}
override func prepareForInterfaceBuilder() {
languagesButton.layer.cornerRadius = buttonsCornerRadius
keyboardSettingsButton.layer.cornerRadius = buttonsCornerRadius
aboutButton.layer.cornerRadius = buttonsCornerRadius
helpButton.layer.cornerRadius = buttonsCornerRadius
}
}
我在我的界面生成器中有这个属性:
但是它从来没有更新我的故事板。当我运行应用程序时,它只是崩溃了,没有任何信息。