IB_DESIGNABLE 设置自定义的UIView可以在IB中渲染
IBInspectable 设置自定义的属性可以在IB的Attributes inspector中直接设置
自定义.h文件
IB_DESIGNABLE
@interface CornerUIImageView : UIImageView
@property (nonatomic, assign) IBInspectable CGFloat cornerRadius;
@property (nonatomic, assign) IBInspectable CGFloat borderWidth;
@property (nonatomic, assign) IBInspectable UIColor *borderColor;
@end
Attributes inspector中的自定义属性:
效果图: