xcode中xib圆角边框

扩展

920 发布: 2021/4/26 20:00 本文总阅读量
xib属性栏快速设置控件的边框、圆角
@interface UIView (RKXibSet)

@property (nonatomic,assign)IBInspectable CGFloat borderWidth;
@property (nonatomic,strong)IBInspectable UIColor *borderColor;
@property (nonatomic,assign)IBInspectable CGFloat cornerRadius;

@end
@interface UIView(RKXibSet)


@end

@implementation UIView (RKXibSet)



- (void)setBorderWidth:(CGFloat)borderWidth{
    if(borderWidth <0) return;
    self.layer.borderWidth = borderWidth;
}

- (void)setBorderColor:(UIColor *)borderColor{
    
    self.layer.borderColor = borderColor.CGColor;
}

- (void)setCornerRadius:(CGFloat)cornerRadius{
    
    self.layer.cornerRadius = cornerRadius;
    self.layer.masksToBounds = cornerRadius >0;
}