我正在使用 xcode 12。我编写了扩展 UI 视图,如下所示:
@IBInspectable
public var shadowRadius: CGFloat {
get {
return layer.shadowRadius
}
set {
layer.shadowRadius = newValue
}
}
@IBInspectable
public var shadowOpacity: Float {
get {
return layer.shadowOpacity
}
set {
layer.shadowOpacity = newValue
}
}
@IBInspectable
public var shadowOffset: CGSize {
get {
layer.shadowOffset
}
set {
layer.shadowOffset = newValue
}
}
@IBInspectable
public var shadowColor: UIColor {
get {
return UIColor(cgColor: layer.shadowColor ?? UIColor.clear.cgColor)
}
set {
layer.shadowColor = newValue.cgColor
}
}
Run Code Online (Sandbox Code Playgroud)
一切正常,但是当我调试视图时,我看到了一些像这样的紫色警告。 …