iOS_XIB draw border color

1. Open the xib file and select the view control that needs to add a border, the effect is shown in the figure
Insert picture description here
2. Click the "+" sign in the above figure to add attributes

// 圆角
layer.masksToBounds
layer.cornerRadius
// 边框
layer.borderWidth
layer.borderColorFromUIColor

3. After adding these, you will find that the border color is not displayed, and you need to add some CALayerextension files. The code is as follows:

@interface CALayer (Category)
- (void)setBorderColorFromUIColor:(UIColor *)color;
@end
@implementation CALayer (Category)
- (void)setBorderColorFromUIColor:(UIColor *)color {
    self.borderColor = color.CGColor;
}
@end

4. After adding these and running again, the border color will appear.

Guess you like

Origin blog.csdn.net/FlyingKuiKui/article/details/102744605