我希望我的应用程序中的选项卡栏项目能够均匀地占据所有选项卡栏,无论是纵向还是横向。我的标签栏上有五个标签。下面的代码没有完成这个任务。我究竟做错了什么?我注意到 screenSize.size.height 实际上引用了宽度,但我不确定为什么会这样。
非常感谢任何帮助。
谢谢
UITabBar *tabBar = self.tabBarController.tabBar;
CGRect screenSize = [[UIScreen mainScreen] bounds];
float width;
if (self.isShowingLandscapeView){
width = screenSize.size.height/5;
}
else {
width = (screenSize.size.width/5);
}
[tabBar setItemWidth:width];
最佳答案
在您的viewDidLoad()
中,设置
tabBar.itemPositioning = .fill
希望这可以帮助别人。
关于ios - 如何均匀设置 UITabBarItem 宽度以占据所有 Tab Bar,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27711237/