[英]Tab Bar - custom images without titles
我想将选项卡栏设置为具有自定义图像,但是XCode坚持在选项卡栏项标题文本中留出空间,以使我的图像在选项卡栏中的位置过高。 我已经在TabBarController.swift viewDidLoad函数中尝试了以下代码:
let tabItems = tabBar.items as [UITabBarItem]
tabItems[0].title = nil
tabItems[0].selectedImage = UIImage(named: "HomeWhiteIcon")
tabItems[1].title = "Database"
tabItems[1].selectedImage = UIImage(named: "Second")
tabItems[2].title = nil
tabItems[2].selectedImage = UIImage(named: "SettingsWhiteIcon")
tabItems[3].title = nil
tabItems[3].selectedImage = UIImage(named: "ReportsWhiteIcon")
但是,尽管未显示标题,但图像的位置太高,如下图所示(请忽略数据库图标-我尚未设置此图标。
这是一个随机的刺伤,因为敏捷不是我的强项,但是具有标题的数据库图标可能导致整个标题行不折叠。 尝试从数据库图标中删除标题。
否则,您是否看到过setTitlePositionAdjustment
方法? 也许将标题的位置向上调整到图标中,下面的空间将消失。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.