Ever built an app which displays photos and can’t decide which is the best UIStatusBarStyle
to use, because there isn’t one that will work with every photo?
Max Howell (who wrote Homebrew) has 2 Cocoapods that will help with that:
Combining them, you can use the luminance of the UIImage
instance to figure out whether UIStatusBarStyleLightContent
or UIStatusBarStyleDefault
is more appropriate:
#import "UIImage+AverageColor.h"
#import "UIColor+PerceivedLuminance.h"
@implementation MyViewController
- (UIStatusBarStyle)preferredStatusBarStyle {
return self.topImageView.image.averageColor.perceivedLuminance > 0.5
? UIStatusBarStyleLightContent
: UIStatusBarStyleDefault;
}
@end
Try it out.
Your feedback is valuable: Do you want more nuggets like this? Yes or No
.
.