我正在尝试在我的 IOS 项目中创建一个自定义按钮。但是当我用我的班级创建按钮时,背景在情节提要中不起作用。但是当我运行程序时,按钮工作正常。
在这里你看到我的课
@IBDesignable class GreenButtonTest : UIButton{
override init(frame: CGRect) {
super.init(frame: frame)
style()
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)!
style()
}
private func style() {
self.backgroundColor = UIColor(CGColor: "#6eb18c".CGColor)
}
}