在SWRevealViewController中切换不起作用

时间:2018-06-10 10:11:49

标签: swrevealviewcontroller

我想创建一个汉堡包按钮。点击按钮它应该显示侧边栏菜单。但它不起作用。请帮帮我。

class HomeViewController:UIViewController,SWRevealViewControllerDelegate {

var button = UIButton()
var barButton = UIBarButtonItem()

override func viewDidLoad() {
    super.viewDidLoad()
    leftbarButton()
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


func leftbarButton(){
    button.setImage(UIImage(named: "hamburger"), for: .normal)
    barButton = UIBarButtonItem(customView: button)
      self.navigationItem.leftBarButtonItem = barButton
    button.addTarget(self, action: #selector(menuAction(sender:)), for: .touchUpInside)
}

@objc func menuAction(sender:UIBarButtonItem){

barButton.target = self.revealViewController()          barButton.action = #selector(SWRevealViewController.revealToggle(_:))

}

}

0 个答案:

没有答案