【发布时间】:2010-07-18 12:03:26
【问题描述】:
我正在尝试设置这样的属性 -
-接口:
@property (readwrite, assign) CGColorRef otherBallColor;
-someMethod:
CGColorRef ballColor = [UIColor colorWithRed:255.0/256.0 green:165.0/256.0 blue:239.0/256.0 alpha:1.0].CGColor;
[self setOtherBallColor:ballColor];
一旦我尝试访问它的值,它就会崩溃 -
-someOtherMethod(本例中为drawRect):
CGContextSetFillColorWithColor(context, otherBallColor);
但如果在“someMethod”中我会这样做 -
CGColorRef ballColor = [UIColor blueColor].CGColor;
...一切正常。谁能解释发生了什么?
非常感谢(PS,Objective-C 很新,一般不会编程)
【问题讨论】:
-
你应该除以 255 而不是 256。
标签: objective-c properties cgcolor