Is it possible to detect the colour of a particular UILabel programatically?
The intention for these lines of code, is to change the background from a red colour, to a white colour. Increase the brightness for a brief second then reduce the brightness and follow up with a label background colour back to red.
The issue is that sometimes, the brightness will increase without the background colour changing. Thus resulting in a major flaw in the design for the application. Which is private.
self.label.backgroundColor = [UIColor colorWithRed:255.0/255 green:255.0/255 blue:255.0/255 alpha: 1.0];
[UIScreen mainScreen].brightness = 1.0;
[self performSelector:@selector(resetColor) withObject:self afterDelay:0.05f ];
- (void)resetColor {
[UIScreen mainScreen].brightness = 0.0;
self.label.backgroundColor = [UIColor colorWithRed:255.0/255 green:0.0/255 blue:0.0/255 alpha:0.5];
Can anyone see why it would randomly not change the background colour beforehand?
And mainly, is it possible to do the following?
if (self.label.backgroundColor == [UIColor whiteColor]){
or while (self.label.backgroundColor == [UIColor whiteColor){
?
your function:
[self performSelector:@selector(resetColor) withObject:self afterDelay:0.05f ];
which of this function called?
to compare the color are extactly the same: use isEqual: instead of == ie
if ([self.label.backgroundColor isEqual:[UIColor whiteColor]])
otherwise, you should compare the all of Color's elements, ie RGBA
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.