1.首先是Pods导入
2.oc-swift桥接文件中 #import "SWRevealViewController/SWRevealViewController.h"
3.对应容器子视图文件中导入 import SWRevealViewController
4.Main.storyboard中建立空的view容器(设置空view的Class属性为SWRevealViewController),对应连线子i容器设置转场方式为 reveal view controller set Controller
5.接下来设置两个Segue 的 identifier, 设置成“sw_front”,告诉 SWRevealViewController 这是前置控制器。rear英文就是后背的意思,这里设置sw_rear就是告诉SWRevealViewController这是后背控制器
6.初始化容器:
func initSwRevealViewController() {
if let revealVC = revealViewController() {
revealVC.rearViewRevealWidth = 280
navigationItem.leftBarButtonItem?.target = revealVC
navigationItem.leftBarButtonItem?.action = #selector(revealVC.revealToggle(_:))
view.addGestureRecognizer(revealVC.panGestureRecognizer())
}
}
网友评论