I want to know if there is a way to change the iOS 7 status bar text color besides black and white color?
Theoretically this is possible. You will need to read about private api's on iOS. Here is o good place to start with UIStatusBar example:
http://b2cloud.com.au/tutorial/using-private-ios-apis/
Keep in mind that probably you won't be able to submit your app on Appstore if you would use private api.
Put this in your AppDelegate application:didFinishLaunchingWithOptions:
Swift 4.2:
if UIApplication.shared.responds(to: Selector(("statusBar"))),
let statusBar = UIApplication.shared.value(forKey: "statusBar") as? UIView,
statusBar.responds(to: #selector(getter: CATextLayer.foregroundColor)) {
statusBar.setValue(UIColor.red, forKey: "foregroundColor")
}
Swift 3.0:
Just in case Apple decides to change the naming of the class (highly unlikely) we shall add some type-safety.
if application.responds(to: Selector(("statusBar"))),
let statusBar = application.value(forKey: "statusBar") as? UIView,
statusBar.responds(to: Selector(("foregroundColor"))) {
statusBar.setValue(UIColor.red, forKey: "foregroundColor")
}
Swift 2.0:
application.valueForKey("_statusBar")?.setValue(UIColor.redColor(), forKey: "_foregroundColor")
Objective-C:
[[application valueForKey:@"_statusBar"] setValue: [UIColor redColor] forKey: @"_foregroundColor"];
It's hard to say if your app will be rejected from the app store. Using KVC to access the _statusBar
property will not get your app rejected as the UIApplication
class itself is not hidden.
That being said, neither is the UIStatusBar
class hidden, ie. it's not in the SDK's PrivateFrameworks directory nor marked with __attribute__((visibility("hidden")))
nor does the class name begin with an underscore.
If your app was rejected because of using this please comment below so I can update the answer.