freshoffthedevboat freshoffthedevboat - 29 days ago 9
Objective-C Question

Trying to use a custom UIColor instance (ObjC)

What's wrong with my code?

- (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];
}


I have tried initialising the color variables and
UIColor
everywhere but I keep getting below error:


no known class method for selector 'color'


even though it's right there!

Answer
self.Label.textColor = color; self.Label2.textColor = color;
Comments