The status bar background disappears hiding on iOS 11

Like iOS 11, the status bar in my application is erroneous when I reject it. The background of the status bar becomes clear when the status bar is rejected. In iOS 10, this was not done.

status bar error

I recreated the problem in a very simple application that I downloaded on Github: TestStatusBarBug . Here is all the relevant code:

AppDelegate.m

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    [[UINavigationBar appearance] setBarTintColor:[UIColor grayColor]];
    return YES;
}

@end

ViewController.m

#import "ViewController.h"

@interface ViewController () {
    BOOL _statusBarHidden;
}

@end

@implementation ViewController

-(BOOL)prefersStatusBarHidden
{
    return _statusBarHidden;
}

-(UIStatusBarAnimation)preferredStatusBarUpdateAnimation
{
    return UIStatusBarAnimationSlide;
}

- (IBAction)toggleStatusBar {
    _statusBarHidden = !_statusBarHidden;

    [UIView animateWithDuration:0.35 animations:^{
        [self setNeedsStatusBarAppearanceUpdate];
    }];
}

@end

Has anyone else experienced this issue? Is there a fix or workaround?

+6
source share
1 answer

, , , , , ( ).

, ( 20 ), . / , .

iOS 11, , , iOS. , .

, . , .

.

- (IBAction)toggleStatusBar {
    _statusBarHidden = !_statusBarHidden;

    [UIView animateWithDuration:0.35 animations:^{
        [self setNeedsStatusBarAppearanceUpdate];
        [self.navigationController.navigationBar setNeedsLayout];
        [self.navigationController.navigationBar layoutIfNeeded];
    }];
}

+4

All Articles