swift开发笔记28 SlideBarMenu
2018-01-05 17:24 dengchaojie_learner 阅读(212) 评论(0) 编辑 收藏 举报、、extension给原类,添加属性和方法
extension Selector {
static let toMenu = #selector(SWRevealViewController.revealToggle(_:))
static let toExtra = #selector(SWRevealViewController.rightRevealToggle(_:))
}
extension UIViewController {
func addSideBarMenu(_ leftBarButtonItem: UIBarButtonItem?, rightBarButtonItem: UIBarButtonItem? = nil) -> Void
{
if let revealVC = revealViewController() {
if let leftItem = leftBarButtonItem {
leftItem.target = revealVC
leftItem.action = Selector.toMenu
}
if let rightItem = rightBarButtonItem {
revealVC.rightViewRevealWidth = 150
rightItem.target = revealVC
rightItem.action = Selector.toExtra
}
view.addGestureRecognizer(revealVC.panGestureRecognizer())
}
}
}
、、开源lib
SWRevealViewController