5
在Storyboard中为view添加圆角等扩展属性
source link: https://www.devashen.com/blog/2020/06/24/kuozhan/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
在Storyboard中为view添加圆角等扩展属性
Jun 24th, 2020 5:51 pm | 评论
为了方便在Storyboard面板中给View设置圆角属性, 实现和原生其他属性一样设置的方式. 现通过IBInspectable
在storyboard中给view添加扩展属性;
extension UIView {
@IBInspectable var cornerRadius: CGFloat {
get {
return layer.cornerRadius
}
set {
layer.cornerRadius = newValue
}
}
@IBInspectable var maskToBounds: Bool {
get {
return layer.masksToBounds
}
set {
layer.masksToBounds = newValue
}
}
@IBInspectable var borderColor: UIColor {
get {
return UIColor.init(cgColor: layer.borderColor!)
}
set {
layer.borderColor = newValue.cgColor
}
}
@IBInspectable var borderWidth: CGFloat {
get {
return layer.borderWidth
}
set {
layer.borderWidth = newValue
}
}
}
Posted by Ashen
Jun 24th, 2020 5:51 pmiOS
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK