尝试使用自定义 UIColor 实例 (ObjC)
Trying to use a custom UIColor instance (ObjC)
我的代码有什么问题?
- (IBAction)randomColour:(id)sender {
CGFloat hue = ( arc4random() % 256 / 256.0 ); // 0.0 to 1.0
CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from white
CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from black
UIColor *color = [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
self.Label.textColor = [UIColor color];
self.Label2.textColor = [UIColor color];
}
我已经尝试在各处初始化颜色变量和 UIColor
,但我总是遇到以下错误:
no known class method for selector 'color'
即使它就在那里!
self.Label.textColor = color; self.Label2.textColor = color;
我的代码有什么问题?
- (IBAction)randomColour:(id)sender {
CGFloat hue = ( arc4random() % 256 / 256.0 ); // 0.0 to 1.0
CGFloat saturation = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from white
CGFloat brightness = ( arc4random() % 128 / 256.0 ) + 0.5; // 0.5 to 1.0, away from black
UIColor *color = [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:1];
self.Label.textColor = [UIColor color];
self.Label2.textColor = [UIColor color];
}
我已经尝试在各处初始化颜色变量和 UIColor
,但我总是遇到以下错误:
no known class method for selector 'color'
即使它就在那里!
self.Label.textColor = color; self.Label2.textColor = color;