1,Swift学习笔记一导航栏 item的设定;

来源:互联网 发布:sas高校数据分析大赛 编辑:程序博客网 时间:2024/05/16 17:07

 很多页面界面商会用到导航栏上定义按钮的效果,笔记记录系统自带的设置方法;

代码如下:

 override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.

//设置为图像按钮的的方法,系统还有文字等等rightAction为按钮执行的方法

        let img = UIImage(named: "setting")
        let rightItem = UIBarButtonItem(image: img, style: UIBarButtonItemStyle.plain, target: self, action: #selector(rightAction))
        self.navigationItem.rightBarButtonItem =  rightItem;
        //此处注释的方法是使用系统的文字的设置;

//        let rigth = UIBarButtonItem(title: "设置", style: UIBarButtonItemStyle.plain, target: self, action: #selector(rightAction))
//        self.navigationItem.rightBarButtonItem = rigth;

    }

按钮执行方法一般都是跳转界面和弹出框的界面等等这里代码展示使用push跳转界面

 func rightAction() {
    let vc = SettingController()
        vc.hidesBottomBarWhenPushed = true
        self.navigationController?.pushViewController(vc, animated: true);
    }

原创粉丝点击