gpt4 book ai didi

swift - 如何使用 UITabBarController 实现此布局

转载 作者:搜寻专家 更新时间:2023-11-01 06:26:18 26 4
gpt4 key购买 nike

我正在以编程方式构建 UITabBarController,并且需要按以下方式对齐我的标签栏图标/文本。

这可能吗?我不确定应该更改哪些属性?

enter image description here

最佳答案

您可以尝试移动 UITabBarItem 的标题和图像

开始将整个标题向左和向上移动

enter image description here

然后将图片向右和向下移动

enter image description here


enter image description here

...请注意,这适用于自定义图像,不适用于系统项目


现在您可以更懒惰并创建 UITabBar 的自定义子类

class CustomTabBar: UITabBar {
override func awakeFromNib() {
items?.forEach {
$0.titlePositionAdjustment = UIOffset(horizontal: -20, vertical: -20)
$0.imageInsets = UIEdgeInsets(top: 3, left: 30, bottom: -3, right: -30)
}
}
}

关于swift - 如何使用 UITabBarController 实现此布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54052253/

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