选中xib中的button,在右边栏的第三个标签页中第三项是User Defined Runtime Attributes
添加一个keyPath,keyPath值为layer.borderWidth,类型为NSNumber,值为你想要设置的边框宽度。如图:
第二个是设置边框的颜色,上面设置颜色无效 这时候需要给CALayer增加一个分类
然后 代码如下
//// CALayer+XibConfiguration.h Copyright
//#import@interface CALayer (XibConfiguration)
// This assigns a CGColor to borderColor.
@property(nonatomic, assign) UIColor *borderUIColor;
@end
//
// CALayer+XibConfiguration.m
//
//
// All rights reserved.
//
#import "CALayer+XibConfiguration.h"
@implementation CALayer (XibConfiguration)
-(void)setBorderUIColor:(UIColor*)color
{
self.borderColor = color.CGColor;
}
-(UIColor*)borderUIColor
{
return [UIColor colorWithCGColor:self.borderColor];
}
@end