使用IBInspectable在面板上添加属性
作者:
爵笙彦 | 来源:发表于
2016-06-01 17:12 被阅读28次//
// UIView+SKAddition.swift
// kkShop
//
// Copyright (c) 2015年 kk. All rights reserved.
//
@IBDesignable
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 {
if (layer.borderColor != nil) {
return UIColor(CGColor: layer.borderColor!)
}
return self.backgroundColor
}
set {
layer.borderColor = newValue?.CGColor
}
}
}
本文标题:使用IBInspectable在面板上添加属性
本文链接:https://www.haomeiwen.com/subject/pxvhdttx.html
网友评论