【发布时间】:2015-03-07 02:53:52
【问题描述】:
我想将我的标签栏设置为具有自定义图像,但 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")
然而,虽然没有显示标题,但图像位置太高,如下图所示(请忽略数据库图标 - 我尚未设置此图标。
【问题讨论】: