我可以在 SOTabBar 库中的按钮下设置文本吗?
Can I set text under buttons in SOTabBar library?
我使用 SOTabBar 库,在文档中没有说明选项卡下的文本。有人使用它并在其下设置一些文字吗?
是否可以在带有 UILabel 的选项卡按钮下添加一些视图并设置文本的解决方案?这不会对所有设备都有响应...That's my tab menu, at this point customers doesn't understand what tab means
一个好的起点始终是存储库中的示例。在不知道您当前的方法的情况下,您可以尝试类似的方法。
class ViewController: SOTabBarController {
override func loadView() {
super.loadView()
SOTabBarSetting.tabBarTintColor = #colorLiteral(red: 2.248547389e-05, green: 0.7047000527, blue: 0.6947537661, alpha: 1)
SOTabBarSetting.tabBarCircleSize = CGSize(width: 60, height: 60)
}
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
let homeStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "HOME_ID")
let chatStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "CHAT_ID")
let sleepStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "SLEEP_ID")
let musicStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MUSIC_ID")
let meStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ME_ID")
homeStoryboard.tabBarItem = UITabBarItem(title: "Home", image: UIImage(named: "home"), selectedImage: UIImage(named: "home_Selected"))
chatStoryboard.tabBarItem = UITabBarItem(title: "Chat", image: UIImage(named: "chat"), selectedImage: UIImage(named: "chat_Selected"))
sleepStoryboard.tabBarItem = UITabBarItem(title: "Sleep", image: UIImage(named: "moon"), selectedImage: UIImage(named: "moon_Selected"))
musicStoryboard.tabBarItem = UITabBarItem(title: "Music", image: UIImage(named: "music"), selectedImage: UIImage(named: "music_Selected"))
meStoryboard.tabBarItem = UITabBarItem(title: "Me", image: UIImage(named: "menu"), selectedImage: UIImage(named: "menu_Selected"))
viewControllers = [homeStoryboard, chatStoryboard,sleepStoryboard,musicStoryboard,meStoryboard]
}
}
如果需要,您可以通过 viewController.tabBarItem.title
访问标题
Link 到 relevant example
我使用 SOTabBar 库,在文档中没有说明选项卡下的文本。有人使用它并在其下设置一些文字吗?
是否可以在带有 UILabel 的选项卡按钮下添加一些视图并设置文本的解决方案?这不会对所有设备都有响应...That's my tab menu, at this point customers doesn't understand what tab means
一个好的起点始终是存储库中的示例。在不知道您当前的方法的情况下,您可以尝试类似的方法。
class ViewController: SOTabBarController {
override func loadView() {
super.loadView()
SOTabBarSetting.tabBarTintColor = #colorLiteral(red: 2.248547389e-05, green: 0.7047000527, blue: 0.6947537661, alpha: 1)
SOTabBarSetting.tabBarCircleSize = CGSize(width: 60, height: 60)
}
override func viewDidLoad() {
super.viewDidLoad()
self.delegate = self
let homeStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "HOME_ID")
let chatStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "CHAT_ID")
let sleepStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "SLEEP_ID")
let musicStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "MUSIC_ID")
let meStoryboard = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "ME_ID")
homeStoryboard.tabBarItem = UITabBarItem(title: "Home", image: UIImage(named: "home"), selectedImage: UIImage(named: "home_Selected"))
chatStoryboard.tabBarItem = UITabBarItem(title: "Chat", image: UIImage(named: "chat"), selectedImage: UIImage(named: "chat_Selected"))
sleepStoryboard.tabBarItem = UITabBarItem(title: "Sleep", image: UIImage(named: "moon"), selectedImage: UIImage(named: "moon_Selected"))
musicStoryboard.tabBarItem = UITabBarItem(title: "Music", image: UIImage(named: "music"), selectedImage: UIImage(named: "music_Selected"))
meStoryboard.tabBarItem = UITabBarItem(title: "Me", image: UIImage(named: "menu"), selectedImage: UIImage(named: "menu_Selected"))
viewControllers = [homeStoryboard, chatStoryboard,sleepStoryboard,musicStoryboard,meStoryboard]
}
}
如果需要,您可以通过 viewController.tabBarItem.title
Link 到 relevant example