gpt4 book ai didi

ios - 快速调整标签栏大小后调整 subview 大小

转载 作者:行者123 更新时间:2023-11-29 00:19:15 24 4
gpt4 key购买 nike

我正在使用一个 UIViewController,它从 TabBarController 继承了一个选项卡栏,在其中,我有一个 UITableView,其底部空间设置为等于底部布局指南顶部,如下所示:

enter image description here

然后我使用这段代码来调整我的标签栏的大小

let barHeight: CGFloat = 40.0

override func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()

var tabFrame = tabBar.frame
tabFrame.size.height = barHeight
tabFrame.origin.y = view.frame.size.height - barHeight - 1
tabBar.frame = tabFrame
}

但似乎在调整标签栏大小之前表格 View 已经布置好,结果是这样的

enter image description here

有没有办法动态调整 subview 的大小,使其仍然遵循相同的布局?

最佳答案

这对我有用

extension UITabBar {
override open func sizeThatFits(_ size: CGSize) -> CGSize {
var sizeThatFits = super.sizeThatFits(size)
sizeThatFits.height = 40

return sizeThatFits
}
}

关于ios - 快速调整标签栏大小后调整 subview 大小,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44453029/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com