我可以在模拟器上查看使用IBInspectable所做的更改,但不能在情节提要中查看
我尝试重新安装Xcode,但没有解决此问题。这是一些屏幕截图:


因此,我知道我的代码运行正常,因为它在模拟器中运行,并且这是一个新项目,因此我没有任何“ Storyboard可能仍在加载更改”的问题。
import UIKit
extension UIView {
@IBInspectable
var cornerRadius: CGFloat {
get {
return layer.cornerRadius
}
set {
layer.cornerRadius = newValue
layer.masksToBounds = newValue > 0
}
}
@IBInspectable
var borderWidth: CGFloat {
get {
return layer.borderWidth
}
set {
layer.borderWidth = newValue
}
}
@IBInspectable
var borderColor: UIColor? {
get {
let color = UIColor(cgColor: layer.borderColor!)
return color
}
set {
layer.borderColor = newValue?.cgColor
}
}
@IBInspectable
var shadowRadius: CGFloat {
get {
return layer.shadowRadius
} …Run Code Online (Sandbox Code Playgroud)