推送到控制器并设置hidesBottomBarWhenPushed后,UILabel放错位置

时间:2022-11-17 19:19:12

Having a bit of an issue with my tab bar app. I want to hide the bottom bar in the next controller I push to. I have set the hidesBottomBarWhenPushed to true in the IB. I have a UILabel pinned to the bottom of the screen in this controller. When I push to it the label is not at the bottom of the screen but above it at the same height the toolbar was. Any ideas what I might be doing wrong here? Any pointers would be great!

我的标签栏应用程序有点问题。我想隐藏下一个控制器中的底栏。我在IB中将hidesBottomBarWhenPushed设置为true。我有一个UILabel固定在这个控制器的屏幕底部。当我按下它时,标签不在屏幕的底部,而是在工具栏的相同高度上方。我在这里做错了什么想法?任何指针都会很棒!

1 个解决方案

#1


0  

Not the cleanest of solutions, but you could rearrange the label when the BottomBar gets hidden

不是最干净的解决方案,但是当BottomBar被隐藏时你可以重新排列标签

Like this:

label.frame = CGRect(x: label.frame.origin.x, y: label.frame.origin.y + 'tabbarHeight', width: label.frame.width, height: label.frame.height)

You would just have to add the height of your tabBar to the y value

您只需将tabBar的高度添加到y值即可

Edit: This is also reversible, so when you are navigating back, just subtract the tabBarHeight from the y value

编辑:这也是可逆的,因此当您向后导航时,只需从y值中减去tabBarHeight

#1


0  

Not the cleanest of solutions, but you could rearrange the label when the BottomBar gets hidden

不是最干净的解决方案,但是当BottomBar被隐藏时你可以重新排列标签

Like this:

label.frame = CGRect(x: label.frame.origin.x, y: label.frame.origin.y + 'tabbarHeight', width: label.frame.width, height: label.frame.height)

You would just have to add the height of your tabBar to the y value

您只需将tabBar的高度添加到y值即可

Edit: This is also reversible, so when you are navigating back, just subtract the tabBarHeight from the y value

编辑:这也是可逆的,因此当您向后导航时,只需从y值中减去tabBarHeight