mike vorisis mike vorisis - 1 year ago 112
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 Source

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)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download