5 自定义访客视图

2017-05-13  本文已影响0人  rebeccaBull
import UIKit

class LYVisitorVc: UITableViewController {

    var isLogin: Bool = false
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
    }
    
    func setupNavUI() {
        
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", target: self, action:#selector(registerButtonAction))
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", target: self, action:#selector(loginButtonAction))
    }

    
    @objc private func registerButtonAction() {
        
        print("注册")
        
    }
    
    @objc private func loginButtonAction() {

        print("denglu")
        
    }

    
    
    //自定义视图重写 loadView
    override func loadView() {
        
        if isLogin == false {
            
            //没有登录,自定义访客视图
            let visitorV = UIView()
            visitorV.backgroundColor = UIColor.yellow
            view = visitorV
            
            setupNavUI()
            
        } else {
            
            //登录
            super.loadView()
            
        }
    }
    
}
上一篇 下一篇

猜你喜欢

热点阅读