Sha*_*yrs 25 objective-c uitabbaritem uitabbar ios xcode4.5

这是我打算在屏幕上显示的自定义标签栏.但是,我的合作伙伴希望文本略微提升.我怎么能这样做?
Sri*_*aju 47
为什么不为视图控制器设置空标题属性并将标题添加到标签的自定义图像?
更新:为了完整答案; 来自评论和ios tabbar在没有图像时将文本放在中间
[tab.tabBarItem setTitlePositionAdjustment:UIOffsetMake(0, -10)]
Tim*_*own 35
您可能希望全局应用此偏移量,因此我建议
OBJ-C
[UITabBarItem appearance].titlePositionAdjustment = UIOffsetMake(0, -4);
Run Code Online (Sandbox Code Playgroud)
迅速:
UITabBarItem.appearance().titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -4)
Run Code Online (Sandbox Code Playgroud)
对于 iOS 13 及更高版本:
if #available(iOS 13, *) {
let appearance = UITabBarAppearance()
appearance.stackedLayoutAppearance.selected.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -10)
appearance.stackedLayoutAppearance.normal.titlePositionAdjustment = UIOffset(horizontal: 0, vertical: -10)
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
20013 次 |
| 最近记录: |