navigationBar.isTranslucent = false,控制器受导航栏影响

如果不将navigationbar.translucent = true 会觉得颜色很浅,因为这是半透明状态

若navigationbar.translucent = false,颜色问题解决,但是子控制器视图整体下移

虽然以下代码设置了,但有时候还有bug,我是在做透明渐变不透明导航栏的时候出bug。

        if #available(iOS 11.0, *) {

            tableView.contentInsetAdjustmentBehavior = .never

        }else {

            self.automaticallyAdjustsScrollViewInsets = false

        }

这时候就要在viewDidLoad方法里设置

self.extendedLayoutIncludesOpaqueBars = true

或者在xib中是勾选ViewContorller的如下选项

under Opaque Bars

意思就是可以在不透明的导航栏之下。

猜你喜欢

转载自blog.csdn.net/feifeiwuxian/article/details/82143996
今日推荐