ksnowlv

回顾过去,总结以往;立足现在,铭记当下;技术为主,笔记而已.

IB_DESIGNABLE与IBInspectable的使用

| Comments

iOS开发中经常会用到一些自定义UI控件,控件的效果和属性可以通过IB_DESIGNABLEIBInspectable预览和修改。

IB_DESIGNABLE

自定义 UIView 可以在 XIB 中预览,,查看自定义控件的效果。

IBInspectable

自定义 UIView 的属性出现在 XIB 中 Attributes inspector,可以通过修改属性,在XIB中查看效果 。

示例如下:

1
2
3
4
5
6
IB_DESIGNABLE//在 XIB 中预览控件
@interface YKNavigationBar : UIView
@property (nonatomic, strong) IBInspectable NSString *barTitle;
@property (nonatomic, assign) IBInspectable double titleFontSize;
@property (nonatomic, strong) IBInspectable UIColor *titleShadowColor;
@property (nonatomic, strong) IBInspectable UIColor *titleColor;

image

Comments

comments powered by Disqus
Included file 'custom/after_footer.html' not found in _includes directory