介绍
SS_SlideMenu是Swift版本的侧滑菜单栏 , 对iPhoneX也做了适配 , 高度封装 , 同时也开放了一些接口可以自己配置参数 , 使用起来也很简单 , 耦合性较低
1.效果图
iPhone8P.gifiPhoneX.gif
2.使用方法
- 初始化
self.slideMenuVC = SS_SlideMenuViewController.init(menuController: demoMenuVC, mainController: demoNavigationVC)
, 可以在AppDelegate中使用
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
self.window = UIWindow.init(frame: UIScreen.main.bounds)
let demoMenuVC = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "DemoMenuViewControllerID")
let demoMainVC = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "DemoMainViewControllerID")
let demoNavigationVC = UINavigationController(rootViewController: demoMainVC)
self.slideMenuVC = SS_SlideMenuViewController.init(menuController: demoMenuVC, mainController: demoNavigationVC)
// self.slideMenuVC = SS_SlideMenuViewController.init(menuController: demoMenuVC, mainController: demoNavigationVC, backgroundImageName: "fx_mobileLive_mine_concern_bg2", slideScale: 1.0)
// self.slideMenuVC = SS_SlideMenuViewController.init(menuController: demoMenuVC, mainController: demoNavigationVC, backgroundImageName: "fx_mobileLive_mine_concern_bg3", slideScale: 1.0, slideDistanceScale: CGFloat(5.0/6.0))
self.window?.rootViewController = self.slideMenuVC
self.window?.makeKeyAndVisible()
return true
}
- 开放打开菜单栏和关闭菜单栏的接口
func openMenu() func closeMenu()
, 可以根据具体需求打开或者关闭菜单栏
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.slideMenuVC?.openMenu()
- 点击菜单栏中的某一项,使主界面跳转,并且关闭菜单栏
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let appDelegate = UIApplication.shared.delegate as! AppDelegate
appDelegate.slideMenuVC?.closeMenu()
let demoNextVC = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "NextViewControllerID")
let navigationVC = appDelegate.slideMenuVC?.mainController as? UINavigationController
navigationVC?.pushViewController(demoNextVC, animated: true)
}
网友评论