mike vorisis mike vorisis - 3 days ago 6
Swift Question

How to manage SWRevealViewController with button

I tried to implemented the SWRevealViewController to my project, but I want to do it with a button and all documentations I found are for barbuttonitems that have this code:

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


How can I do it with a simple button?

Answer

do like

let revealViewController = self.revealViewController()
var settingsButton = UIButton(type: .custom)
settingsButton.setImage(UIImage(named: "settings_icon")!, for: .normal)
settingsButton.addTarget(revealViewController, action: #selector(SWRevealViewController.revealToggle(_:)), for: .touchUpInside)
View.addGestureRecognizer(self.revealViewController().panGestureRecognizer())
Comments