圆角
- 圆角代码实现:
xx.layer.cornerRadius = 5
xx.layer.masksToBounds = true
- 圆角User Defined Runtime Attributes实现:
layer.cornerRadius Number 5
layer.masksToBounds Boolean true
边框
- 边框代码实现:
xx.layer.borderWidth = 0.5
xx.layer.borderColor = UIColor()
- 边框User Defined Runtime Attributes实现:
layer.borderWidth Number 0.5
layer.borderUIColor Color () ——需要扩展CALayer才能实现
扩展系统CALayer类:
extension CALayer {
var borderUIColor: UIColor {
get {
return UIColor(cgColor: self.borderColor!)
}
set {
self.borderColor = newValue.cgColor
}
}
}
网友评论