I believe there is no API/method to change the status bar color other than setting the style(default/light). But the below workaround works. Can we use this workaround or we need to stick with the style as there is no straight forward API to change color?
UIView *statusbar = [[[UIApplication sharedApplication] valueForKey:@"statusBarWindow"] valueForKey:@"statusbar"];
statusbar.backgroundColor = [UIColor whiteColor];//set whatever color you like
Can we use this workaround
You need to have two things in mind:
- This sort of KVC access to private properties can be treated as using Private APIs. Apple may reject your app with the reason using private APIs. Someone would say "my app using this code is approved by Apple recently", but that does not guarantee your app would be approved.
- Apple would change the implementation details at any time with no announcements. Depending on this sort of implementation details makes your app fragile. In the next minor update, those properties might be removed and your app would crash, or it may not work as expected in some conditions even in the current version.
Those risks above are not the things that I would ever like to try.
Anyway, it's your desision to use the workaround or not.
---
ADDITION
If you just want to change the background color, there may be many other ways depending on your view-view controller details.
Please show what sort of design you want to achieve.