Last active
April 4, 2016 10:37
-
-
Save alexruperez/ab5e175d40413faea0a8 to your computer and use it in GitHub Desktop.
Fix SFSafariViewController StatusBar Style, StatusBar Hidden and freezing when swiping back on iOS 9.2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ARSafariViewController.h | |
// | |
// Copyright © 2016 alexruperez. The MIT License (MIT) | |
// | |
@import SafariServices; | |
@interface ARSafariViewController : SFSafariViewController | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// ARSafariViewController.m | |
// | |
// Copyright © 2016 alexruperez. The MIT License (MIT) | |
// | |
#import "ARSafariViewController.h" | |
@interface ARSafariViewController () | |
@property (nonatomic, assign) BOOL isSwipingBack; | |
@end | |
@implementation ARSafariViewController | |
- (UIStatusBarStyle)preferredStatusBarStyle | |
{ | |
if (self.isSwipingBack) | |
{ | |
return [self.presentingViewController preferredStatusBarStyle]; | |
} | |
return [super preferredStatusBarStyle]; | |
} | |
- (BOOL)prefersStatusBarHidden | |
{ | |
if (self.isSwipingBack) | |
{ | |
return [self.presentingViewController prefersStatusBarHidden]; | |
} | |
return [super prefersStatusBarHidden]; | |
} | |
- (void)viewWillDisappear:(BOOL)animated | |
{ | |
self.isSwipingBack = YES; | |
[self.transitionCoordinator notifyWhenInteractionEndsUsingBlock:^(id<UIViewControllerTransitionCoordinatorContext> context) { | |
self.isSwipingBack = NO; | |
}]; | |
[super viewWillDisappear:animated]; | |
} | |
- (void)setIsSwipingBack:(BOOL)isSwipingBack | |
{ | |
_isSwipingBack = isSwipingBack; | |
[self setNeedsStatusBarAppearanceUpdate]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks @bartvandendriessche 👍