2

なぜ私の色のプロパティは常に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
4

2 に答える 2

0

より効果的な色を直接定義する代わりに、カラー RGB 値を使用してみてください。

于 2013-04-23T09:56:10.663 に答える