我收到此警告消息。我该如何解决这个问题。
警告:IB Designables:忽略 UIButton
实例上关键路径 radius
的用户定义运行时属性。尝试设置其值时发生异常:[setValue:forUndefinedKey:]:此类对于键 radius
不符合键值编码。
这是自定义的 UIButtonRounded 类
@IBDesignable class UIButtonRounded: UIButton
{
override func layoutSubviews() {
super.layoutSubviews()
updateCornerRadius()
}
@IBInspectable var rounded: Bool = false {
didSet {
updateCornerRadius()
}
}
@IBInspectable var border: Bool = false {
didSet {
updateCornerRadius()
}
}
@IBInspectable var radious: CGFloat = 0 {
didSet {
updateCornerRadius()
}
}
func updateCornerRadius() {
layer.cornerRadius = rounded ? radious : 0
layer.masksToBounds = true
if(border){
layer.borderWidth = 1.3
layer.borderColor = UIColor(named:"color_bg_white")?.cgColor
}
}
}
提前致谢。
最佳答案
如果您创建一个值并在以后更改它,它仍将存在于身份检查器中用户定义的运行时属性中。去那里删除旧值。
关于ios - 我该如何修复此警告消息。警告 : Ignoring user defined runtime attribute for key path "radius" on instance of "UIButton",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49377734/