Embeded Frameworkに入れる必要もない
IBDesignableで編集が容易なクラスを作成
@IBDesignable
class CardView : UIView {
required init ( coder aDecoder: NSCoder ) {
super. init ( coder: aDecoder)
self . initialize ( )
}
override init ( frame: CGRect ) {
super. init ( frame: frame)
self . initialize ( )
}
func initialize( ) {
println ( " initialize " )
layer. masksToBounds = false
}
@IBInspectable
var borderWidth : CGFloat = 0 {
didSet {
layer. borderWidth = borderWidth
}
}
@IBInspectable
var borderColor : UIColor = UIColor . clearColor ( ) {
didSet {
layer. borderColor = borderColor. CGColor
}
}
@IBInspectable
var cornerRadius : CGFloat = 0 {
didSet {
layer. cornerRadius = cornerRadius
}
}
@IBInspectable
var shadowOffset : CGSize = CGSizeMake ( 0 , 0 ) {
didSet {
layer. shadowOffset = shadowOffset
}
}
@IBInspectable
var shadowRadius : CGFloat = 0 {
didSet {
layer. shadowRadius = shadowRadius
}
}
@IBInspectable
var shadowOpacity : Float = 0 {
didSet {
layer. shadowOpacity = shadowOpacity
}
}
@IBInspectable
var shadowColor : UIColor = UIColor . clearColor ( ) {
didSet {
layer. shadowColor = shadowColor. CGColor
}
}
}
required init ( coder aDecoder: NSCoder ) {
super. init ( coder: aDecoder)
self . initialize ( )
}
override init ( frame: CGRect ) {
super. init ( frame: frame)
self . initialize ( )
}
func initialize( ) {
println ( " initialize " )
layer. masksToBounds = false
var view : UIView = UIView ( frame: CGRectMake ( 10 , 10 , 30 , 30 ) )
view. backgroundColor = UIColor . orangeColor ( )
self . addSubview ( view)
}