Swift Placing TabBar on top of the screen not working in iOS 11

只谈情不闲聊 提交于 2021-02-07 10:51:39

问题


In UITabBarController, I am placing the tab bar on top of the screen using below code :

self.tabBar.frame = CGRectMake(0,0,UIScreen.mainScreen().bounds.width,50)

This works perfectly on iOS 10. But when the same app is installed on iOS11. It placing at the bottom only and not moving up.

Realy dont know what has changed in iOS11
But
How to move tabbar up for iOS 11


回答1:


After so much struggle figured out the solution.

I was placing the tabBar.frame code inside viewDidAppear which works for iOS 10 and below but to support for iOS 11, need to place inside viewDidLayoutSubviews as shown below which is actually the correct method :

override func viewDidLayoutSubviews()
{
    tabBar.frame = CGRectMake(0,0,UIScreen.mainScreen().bounds.width,50)
}


来源:https://stackoverflow.com/questions/47328281/swift-placing-tabbar-on-top-of-the-screen-not-working-in-ios-11

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!