User Defined Runtime Attributes

设置View borderWidth/cornerRadius/borderColor

User Defined Runtime Attributes

为了兼容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

效果

User Defined Runtime Attributes

上一篇:HDU 1863 畅通project (最小生成树是否存在)


下一篇:[cloud][sdn] LBaaS/neutron / Octavia