xib中的label加边框

选中xib中的label,在右边栏的第三个标签页中第三项是User Defined Runtime Attributes

添加一个keyPath,keyPath值为layer.borderWidth,类型为NSNumber,值为你想要设置的边框宽度。

layer.borderWidth

layer.borderColorFromUIColor

如图:

第二个是设置边框的颜色,为了兼容CALayer 的KVC ,你得给CALayer增加一个分类

1
2
3
4
5
6
@implementation CALayer (Additions)
- (void)setBorderColorFromUIColor:(UIColor *)color
{
  self.borderColor = color.CGColor;
}
@end

这种方法只对选中的任意UIView有效,不可选中多个同时进行设置,只能一个一个进行添加,但可以选中Key Path列表中的内容进行复制和粘贴。

原文地址:https://www.cnblogs.com/-yun/p/7299114.html