layer.bordcolor 是CGcolor 所以解决方案就是重写 boderColor 和 shadowColor 这两个 property.
具体办法就是, 写个 CALayer 的 Category.
CALayer+MZXibConfig.h
#import <QuartzCore/QuartzCore.h>
#import <UIKit/UIKit.h>
@interface CALayer (MZXibConfig)
- (void)setBorderColorXib:(UIColor *)color;
- (UIColor *)borderColorXib;
- (void)setShadowColorXib:(UIColor *)color;
- (UIColor *)shadowColorXib;
@end
CALayer+MZXibConfig.m
#import "CALayer+MZXibConfig.h"
@implementation CALayer (MZXibConfig) /
/ MARK: 设置 BorderColor
- (void)setBorderColorXib:(UIColor *)color {
self.borderColor = color.CGColor;
}
- (UIColor *)borderColorXib {
return [UIColor colorWithCGColor:self.borderColor];
}
// MARK: 设置 ShadowColor
- (void)setShadowColorXib:(UIColor *)color {
self.shadowColor = color.CGColor;
}
- (UIColor *)shadowColorXib {
return [UIColor colorWithCGColor:self.shadowColor];
}
@end
在xib的相关属性设置
网友评论