设置View borderWidth/cornerRadius/borderColor
为了兼容CALayer 的KVC ,你得给CALayer增加一个分类
CALayer+BorderColor.h
#import <QuartzCore/QuartzCore.h>
#import <UIKit/UIKit.h>
@interface CALayer (BorderColor)
@property(nonatomic, strong) UIColor *borderColorFromUIColor;
@end
#import "CALayer+BorderColor.h"
#import <objc/runtime.h>
@implementation CALayer (BorderColor)
- (UIColor *)borderColorFromUIColor {
return objc_getAssociatedObject(self, @selector(borderColorFromUIColor));
}
-(void)setBorderColorFromUIColor:(UIColor *)color
{
objc_setAssociatedObject(self, @selector(borderColorFromUIColor), color, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
[self setBorderColorFromUI:self.borderColorFromUIColor];
}
- (void)setBorderColorFromUI:(UIColor *)color
{
self.borderColor = color.CGColor;
}
@end
效果