iOS popViewController 出现动画黑条

标签 ios swift uinavigationbar

我有两个 View Controller 。第一个 View Controller 没有状态栏。

class ViewController: UIViewController {

    override func prefersStatusBarHidden() -> Bool {
        return true
    }

}

另外,我在 Info.plist 中将 UIViewControllerBasedStatusBarAppearance 设置为 YES。

第二个 View Controller 有状态栏。

class SecondViewController: UIViewController {

    override func prefersStatusBarHidden() -> Bool {
        return false
    }
}

他们之间的关系是一个推送segue。

enter image description here

最后一件事是我在 application:didFinishLaunchingWithOptions: 方法中将 translucent 属性设置为 false。

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

    UINavigationBar.appearance().translucent = false
    UINavigationBar.appearance().barTintColor = UIColor.redColor()

    return true
}

当我在导航栏中单击返回时,有一个黑条。如何摆脱它?当我将 translucent 设置为 true 时,黑条消失了。

enter image description here

最佳答案

看完帖子后Explaining difference between automaticallyAdjustsScrollViewInsets, extendedLayoutIncludesOpaqueBars, edgesForExtendedLayout in iOS7 ,我想出了一个解决办法。

extendedLayoutIncludesOpaqueBars 设置为 true。

func viewDidLoad() {
    extendedLayoutIncludesOpaqueBars = true // property introduced in iOS7,default value is false
}

关于iOS popViewController 出现动画黑条,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31209225/

相关文章:

ios - 如何删除 tableview 标题和第一个单元格之间的空间?

ios - CLLocationManager startMonitoringForRegion 会使用 desiredAccuracy 吗?

ios - 当文本改变颜色时,自定义 UIView 将无法正确动画

swift - 有没有一种干净的方法可以将 CNPostalAddress 转换为 CNMutablePostalAddress?

swift - 按下按钮时将 UIViewController .xib 添加到 UIViewController

ios - 发送到实例 Swift NSNotification 的无法识别的选择器

ios - swift: 在将 facebook 当前 token 发送到 AWS Cognito 后接收 AWS id_token?

ios - 导航栏不显示标题

iOS 导航栏不可见

ios - Xcode 7.3.1 : Set background image to UINavigationBar and display back button