设置标题:
self.tabBarItem = “Title”
设置背景色:
self.veiw.backgroundColor = UIColor.blue
设置标签图片:
self.tabBarItem.image = UIImage(named:“iamgeObject”)?.withRenderingMode(UIImageRendringMode.alwaysoriginal)
设置选中下的图片:
self.tabBarItem.selectedImage = UIImage(named:“iamgeObject”)?.withRenderingMode(UIImageRendringMode.alwaysoriginal)
使用系统样式标签:
let item = UITabBarItem(tabBarSystemItem: UITabBarSystemItem.favorite)
self.tabBarItem = item
上述风格可选值有:
more 更多
favorite 最爱
featured 特色
topRated 排行
recents 最近
contacts 联系人
history 历史
bookmarks 书签
search 搜索
downloads 下载
mostRecent 最近
mostViewed 浏览
设置标签提示值:
self.tabBarItem.badgeValue = “99+”
调用初始化方法:
(self.tabBarItem = “Title”
该语句仅当切换到本UITabBarController时才会加载,也就是说未被切换的视图控制器其标题是为空的,为解决该问题需调用视图控制器的初始化方法,使其未被切换时也会显示标题)
init(){
super.init(nibName: nil, bundle: nil)
// Override your init method here.
tabBarItem.title = "INIT"
}
required convience init?(coder aDecoder: NSCoder) {
self.init()
}