美文网首页
swift-导航栏

swift-导航栏

作者: money_ac9e | 来源:发表于2018-08-18 13:38 被阅读0次

swift-导航栏
直接上代码

导航栏整体背景颜色

self.navigationController?.navigationBar.isTranslucent = false
self.navigationController?.navigationBar.backgroundColor = UIColor.red        

导航栏左侧按钮 自定义

let leftItemButton = UIButton(frame: CGRect(x: 0, y: 0, width: 40, height: 44))
        leftItemButton.backgroundColor         = UIColor.clear
        leftItemButton.setTitle("返回" as String, for: UIControlState.normal)
        leftItemButton.setTitleColor(UIColor.black, for: UIControlState.normal)
        leftItemButton.titleLabel?.font        = UIFont.systemFont(ofSize: CGFloat(17.0))
        leftItemButton .addTarget(self, action: #selector(leftClick1), for: UIControlEvents.touchUpInside)
        self.navigationItem.leftBarButtonItem = UIBarButtonItem(customView: leftItemButton)

导航栏左侧 隐藏

self.navigationItem.leftBarButtonItem = nil

导航栏右侧图片

self.navigationItem.rightBarButtonItem = UIBarButtonItem(image: UIImage.init(named: "tarbar1_no"), style: UIBarButtonItemStyle.plain, target: self, action: #selector(leftClick2))

参考:swift导航栏的设置

相关文章

网友评论

      本文标题:swift-导航栏

      本文链接:https://www.haomeiwen.com/subject/kfffiftx.html