學到的2個新的詞 IBDesignable IBInspectable

1.IBDesignable是將代碼中得視圖在xib或者storyboard中顯示, 界面可視

swift中寫在class 前面 @IBDesignable 注意:不是寫在controller的前面,而是寫在需要顯示的視圖的class的前面

OC中 IB_DESIGNABLE 寫在@implementation前面

 

2.IBInspectable 屬性可視

swift中寫在需要顯示的屬性前面 @IBInspectable let height : CGFloat = 10.0f

OC中 IBInspectable @property (nonatomic, assign) height; //額 這個是錯的

應該這麼寫 

IBInspectable CGFloat x; 哈哈

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章