Swift 导航栏的使用
一、基本使用
1.1 创建导航栏
在AppDelegate 如下方法中添加创建导航栏的代码:
func 服务器托管网application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
self.window?.backgroundColor = UIColor.white
let main = ControlMainController()
let navigation = UINavigationController(rootViewController: main)
self.window?.rootViewController = navigation
return true
}
1.2 导航栏上添加按钮
//添加导航栏左边按钮
let item1 = UIBarButtonItem(title: "我的", style: UIBarButtonItem.Style.plain, target: self, action: #selector(buttonClick))
self.navigationItem.leftBarButtonItem = item1
//添加导航栏右边按钮
let item2 = UIBarButtonItem(title: "设置", style: UIBarButtonItem.Style.plain, target: self, action: #selector(buttonClick))
self.navigationItem.rightBarButtonIt服务器托管网em = item2
//添加多个按钮
let item1 = UIBarButtonItem(title: "我的", style: UIBarButtonItem.Style.plain, target: self, action: #selector(buttonClick))
let item2 = UIBarButtonItem(title: "设置", style: UIBarButtonItem.Style.plain, target: self, action: #selector(buttonClick))
self.navigationItem.rightBarButtonItems = [item1, item2]
1.3 页面跳转
//跳转到下个页面
func buttonClick(button:UIButton) {
let secondVC = SecondViewController()
self.navigationController?.pushViewController(secondVC, animated:true)
}
//返回上一个页面
func back() {
self.navigationController?.popViewControllerAnimated(true)
}
服务器托管,北京服务器托管,服务器租用 http://www.fwqtg.net
MySQL数据库 一、MySQL数据库入门 1.初识数据库 数据库(DataBase,DB)是一个存在于计算机存储设备上的数据集合,它可以简单地理解为一种存储数据地仓库。数据库能够长期、高效地管理和存储数据,其主要目的是能够存储(写入)和提供(读取)数据。…