2017-07-21 70 views
1

我试图通过使用包含位置的CGRect来设置组件的位置。navigationBar.IntrinsicContentSize.height与实际栏大小不匹配

pageMenu = CAPSPageMenu(viewControllers: controllerArray, frame: CGRect(x:0.0, y:(self.navigationController?.navigationBar.intrinsicContentSize.height)!, width:self.view.frame.width, height:self.view.frame.height), pageMenuOptions: parameters) 

和y设置为self.navigationController?.navigationBar.intrinsicContentSize.height

但是,当我在模拟器上运行我的应用程序,它显示在导航栏下方的菜单栏。我不知道为什么。我已经将y坐标设置为导航栏的高度。请帮忙。

enter image description here

这是我的故事板。

enter image description here

回答

1

设置此为导航栏下隐藏

viewController.edgesForExtendedLayout = [] 
0

在你的视图控制器视图控制器,你应该设置automaticallyAdjustsScrollViewInsetsfalse

一个布尔值,指示视图控制器是否应该 自动调整其滚动视图插图。

override func viewDidLoad() { 
    super.viewDidLoad() 

    automaticallyAdjustsScrollViewInsets = false 
} 

注意,你还可以通过故事板做到这一点:

enter image description here

通过取消选中此选项。


另外:

由于此属性已不推荐为iOS 11,你可能要检查this Q&A