为什么我的颜色属性总是null
?
@interface StreamingMediaControlButton : UIButton
@property (strong, nonatomic) UIColor *color;
@end
@implementation StreamingMediaControlButton
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
_color = [UIColor whiteColor];
}
return self;
}
- (void)drawRect:(CGRect)rect
{
NSLog(@"color: %@", self.color);
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetFillColorWithColor(context, self.color.CGColor);
}
@end