iOS 状态栏锁定(不随屏幕旋转)

2017-05-16  本文已影响0人  不羁放纵dy

笔者最近遇到一个项目.需要指定VC强制横屏.但是其他页面锁定旋转.效果是达到了.但是出现个小问题.锁定不旋转的页面的StatusBar(状态栏)是旋转的.搜索各种资料没有发现合适的解决办法.自己试验了几个办法.终于实现...分享给大家.

- (NSUInteger)supportedInterfaceOrientations {
     UIViewController *vc =  self.topViewController;
     //如果是需要横屏的页面
     if([vc isKindOfClass:[SignController class]]){
       //则设置状态栏为横屏方向状态
       [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeLeft];
        return UIInterfaceOrientationMaskLandscapeLeft;                           
     }
     //如果是其他页面,则设置状态栏为竖屏方向状态
     [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
     return UIInterfaceOrientationMaskPortrait;
}
上一篇 下一篇

猜你喜欢

热点阅读