I used to think that [UIColor whiteColor] was exactly the same as [UIColor colorWithRed: 1 green: 1 blue: 1 alpha: 1], but it turns out that it is not! Can anyone explain this?
CGFloat red1, green1, blue1, alpha1; UIColor * color1 = [UIColor whiteColor]; [color1 getRed:&red1 green:&green1 blue:&blue1 alpha:&alpha1]; NSLog(@"%f, %f, %f, %f", red1, green1, blue1, alpha1); UIColor * color2 = [UIColor colorWithRed:1 green:1 blue:1 alpha:1]; [color2 getRed:&red1 green:&green1 blue:&blue1 alpha:&alpha1]; NSLog(@"%f, %f, %f, %f", red1, green1, blue1, alpha1);
output:
0.000000, 0.000000, 0.000000, -1.998628 1.000000, 1.000000, 1.000000, 1.000000
This is uncomfortable .. very unpleasant
source share