Swift Tabbar的使用
在 Swift 中使用 UITabBarController 来创建一个具有选项卡界面的应用程序。下面是一个简单的示例,演示如何在 Swift 中使用 UITabBarController:文章来源地址https://www.toymoban.com/news/detail-833336.html
import UIKit
class RootTabbar: UITabBarController {
override func viewDidLoad() {
super.viewDidLoad()
let nav1 = UINavigationController(rootViewController: ControlMainController())
let nav2 = UINavigationController(rootViewController: BusinessMainController())
let nav3 = UINavigationController(rootViewController: OtherMainClassController())
//设置tabBaritem的标题
nav1.tabBarItem.title = "控件"
nav2.tabBarItem.title = "业务"
nav3.tabBarItem.title = "其他"
//设置tabBaritem的普通状态的图标
nav1.tabBarItem.image = UIImage(named:"tabbar_1")
nav2.tabBarItem.image = UIImage(named:"tabbar_2")
nav3.tabBarItem.image = UIImage(named:"tabbar_3")
//设置tabBaritem选中的图标
nav1.tabBarItem.selectedImage = UIImage(named: "tabbar_1a")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
nav2.tabBarItem.selectedImage = UIImage(named: "tabbar_2a")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
nav3.tabBarItem.selectedImage = UIImage(named: "tabbar_3a")?.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
//设置tabBaritem的标题文字颜色
self.tabBar.tintColor = UIColor.COLOR(r: 87, g: 173, b: 57)
self.viewControllers = [nav1, nav2, nav3]
}
}
文章来源:https://www.toymoban.com/news/detail-833336.html
到了这里,关于2.Swift Tabbar的使用的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!