我该如何修复此警告消息。警告:忽略 "UIButton" 实例上关键路径 "radius" 的用户定义运行时属性

How can I fix this warning msg. Warning: Ignoring user defined runtime attribute for key path "radius" on instance of "UIButton"

我收到这条警告消息。我该如何解决这个问题。

警告:IB Designables:忽略 UIButton 实例上关键路径 radius 的用户定义运行时属性。尝试设置其值时遇到异常:[ setValue:forUndefinedKey:]:此 class 与键 radius.

的键值编码不兼容

这里是自定义的UIButtonRoundedclass

@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
       }

    }
}

提前致谢。

它对我有用:

import UIKit

@IBDesignable
class DesignableView: UIView {
}

@IBDesignable
class DesignableButton: UIButton {
}

@IBDesignable
class DesignableLabel: UILabel {
}

extension UIView {

@IBInspectable
var cornerRadius: CGFloat {
    get {
        return layer.cornerRadius
    }
    set {
        layer.cornerRadius = newValue
    }
}

@IBInspectable
var borderWidth: CGFloat {
    get {
        return layer.borderWidth
    }
    set {
        layer.borderWidth = newValue
    }
}

@IBInspectable
var borderColor: UIColor? {
    get {
        if let color = layer.borderColor {
            return UIColor(cgColor: color)
        }
        return nil
    }
    set {
        if let color = newValue {
            layer.borderColor = color.cgColor
        } else {
            layer.borderColor = nil
        }
    }
}

@IBInspectable
var shadowRadius: CGFloat {
    get {
        return layer.shadowRadius
    }
    set {
        layer.shadowRadius = newValue
    }
}

@IBInspectable
var shadowOpacity: Float {
    get {
        return layer.shadowOpacity
    }
    set {
        layer.shadowOpacity = newValue
    }
}

@IBInspectable
var shadowOffset: CGSize {
    get {
        return layer.shadowOffset
    }
    set {
        layer.shadowOffset = newValue
    }
}

@IBInspectable
var shadowColor: UIColor? {
    get {
        if let color = layer.shadowColor {
            return UIColor(cgColor: color)
        }
        return nil
    }
    set {
        if let color = newValue {
            layer.shadowColor = color.cgColor
        } else {
            layer.shadowColor = nil
        }
     }
   }
}

如果您创建一个值并在以后更改它,它仍将存在于身份检查器中用户定义的运行时属性中。去那里删除旧值。