美文网首页
iOS - 高仿酷狗音乐的侧滑菜单栏

iOS - 高仿酷狗音乐的侧滑菜单栏

作者: 冰风v落叶 | 来源:发表于2018-08-09 11:52 被阅读245次

    介绍

    SS_SlideMenu是Swift版本的侧滑菜单栏 , 对iPhoneX也做了适配 , 高度封装 , 同时也开放了一些接口可以自己配置参数 , 使用起来也很简单 , 耦合性较低

    1.效果图

    iPhone8P.gif
    iPhoneX.gif

    2.使用方法

    1. 初始化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
        }
    
    
    1. 开放打开菜单栏和关闭菜单栏的接口func openMenu() func closeMenu() , 可以根据具体需求打开或者关闭菜单栏
            let appDelegate = UIApplication.shared.delegate as! AppDelegate
            appDelegate.slideMenuVC?.openMenu()
    
    1. 点击菜单栏中的某一项,使主界面跳转,并且关闭菜单栏
     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)
        }
    

    3.欢迎在Git上提issue,如有帮助,欢迎star

    相关文章

      网友评论

          本文标题:iOS - 高仿酷狗音乐的侧滑菜单栏

          本文链接:https://www.haomeiwen.com/subject/juuqbftx.html