I need to determine whether a selected UIColor (picked by the user) is dark or bright, so I can change the color of a line of text that sits on top of that color, for better
- (BOOL)isColorLight:(UIColor*)color { CGFloat white = 0; [color getWhite:&white alpha:nil]; return (white >= .85); }
Added Swift 5 version:
Swift 5
var white: CGFloat = 0.0 color.getWhite(&white, alpha: nil) return white >= .85 // Don't use white background