Half screen view , iOS Sidebar Menu

后端 未结 5 2056
清歌不尽
清歌不尽 2021-01-02 13:46

As I want to display number of menus on a left side of a screen just like following-it is a new Facebook application.when you click on bar shown as a red square around it,th

5条回答
  •  耶瑟儿~
    2021-01-02 14:40

    You can use InteractiveSideMenu library. It supports interactive opening/closing menu. It supports interactive opening/closing menu and following customization:

    • Animation duration
    • Visible content width
    • Content scale
    • Using spring animation with params customization
    • Animation options like animation curve

    You should use 3 basic ViewControllers for creating subclasses for implementing your side menu.

    • MenuContainerViewController is a host for menu and content views
    • MenuViewController is a container for menu view
    • MenuItemContentControlller is a container for content that corresponds menu item

    To setup your side menu you shoud do 3 things:

    • Provide implementation of base MenuViewController and assing it to menuViewController property
    • Provide implementation of menu content and assing array of content controllers to contentViewControllers property
    • Select initial content controller by calling selectContentViewController(_ selectedContentVC: MenuItemContentViewController)

    Here is an example of setup Host controller.

    import InteractiveSideMenu
    
    class HostViewController: MenuContainerViewController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            self.menuViewController = self.storyboard!.instantiateViewController(withIdentifier: "NavigationMenu") as! MenuViewController
    
            self.contentViewControllers = contentControllers()
    
            self.selectContentViewController(contentViewControllers.first!)
        }
    
        private func contentControllers() -> [MenuItemContentViewController] {
            //here is instantiation of content view controllers
        }
    }
    

    You can find more details in the example here.

提交回复
热议问题