Status Bar showing black text, only on iPhone 6 iOS 8 simulator

前端 未结 14 859
伪装坚强ぢ
伪装坚强ぢ 2020-12-07 20:16

I\'m trying to convert my iOS 7 app to iOS 8 in Xcode 6 GM, and when i run it on the iPhone 5s or lower simulators with iOS 8 everything is fine, but on the iPhone 6 and 6 P

相关标签:
14条回答
  • 2020-12-07 21:02

    My app's status bar was working fine in iOS 7 using only the project/target settings:

    Status bar style = UIStatusBarStyleLightContent
    

    and

    View controller-based status bar appearance = NO
    

    but in iOS 8 (iPhone 6 and iPhone 6 Plus simulators) the status bar was not showing up. Changing View controller-based status bar appearance to YES and then adding:

        // Objective C
        - (UIStatusBarStyle) preferredStatusBarStyle {
             return UIStatusBarStyleLightContent;
        }
        //Swift
        override func preferredStatusBarStyle() -> UIStatusBarStyle {
        return UIStatusBarStyle.LightContent
        }
    

    to the ViewController resulted in seeing the white status bar again, but only after the initial root controller launches. During the initial launch the status bar remains black.

    0 讨论(0)
  • 2020-12-07 21:05

    Add the following line in AppDelegate's didFinishLaunchingWithOptions: method

    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleBlackOpaque animated:NO];
    
    0 讨论(0)
  • 2020-12-07 21:08

    Here is Apple Guidelines/Instruction about status bar/text color change.

    Here is - How to change status bar style:

    If you want to set status bar style, application level then set UIViewControllerBasedStatusBarAppearance to NO in your `.plist' file.

    Or programatically you can do from App Delegate:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        application.statusBarStyle = .lightContent
        return true
    }
    

    if you wan to set status bar style, at view controller level then follow these steps:

    1. Set the UIViewControllerBasedStatusBarAppearance to YES in the .plist file, if you need to set status bar style at UIViewController level only.
    2. In the viewDidLoad add function - setNeedsStatusBarAppearanceUpdate

    3. override preferredStatusBarStyle in your view controller.

    -

    override func viewDidLoad() {
        super.viewDidLoad()
        self.setNeedsStatusBarAppearanceUpdate()
    }
    
    override var preferredStatusBarStyle: UIStatusBarStyle {
        return .lightContent
    }
    

    Set value of .plist according to status bar style setup level. enter image description here

    0 讨论(0)
  • 2020-12-07 21:08

    I have performed following steps and they worked for me quite well, should be working in iOS 8+ as well.

    1) Added property View controller-based status bar appearance => NO in Info.plist.
    2) Add following piece of code in - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions of AppDelegate.m

        [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
        [self.window setBackgroundColor:[UIColor redColor]]; // Change color as per need.
    

    3) Override method in ViewController

    - (UIStatusBarStyle) preferredStatusBarStyle {
        return UIStatusBarStyleLightContent;
    }
    
    0 讨论(0)
  • 2020-12-07 21:13

    So here is how I fixed it

    In PLIST View Controller Based Status Bar NO Status Bar Style UIStatusBarStyleLightContent

    In AppDelegate DidFinishLaunching

    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
        [self.window setBackgroundColor:[UIColor whiteColor]];
    

    In Each View Controller

    - (UIStatusBarStyle) preferredStatusBarStyle {
        return UIStatusBarStyleLightContent;
    }
    
    0 讨论(0)
  • 2020-12-07 21:13

    A good fix for this is to use the new launch image nib support which gets used on the iPhone 6 models. It seems like there's just a bug in iOS 8 that means that the iPhone 6 models don't check the status bar style correctly when launching but it gets solved if you add in the launch nib.

    As Aaron Wasserman pointed out you can also specify iPhone 6 & 6+ launch PNGs and that seems to fix the problem too, so long as you set them up right!

    0 讨论(0)
提交回复
热议问题