Half screen view , iOS Sidebar Menu

后端 未结 5 1967
清歌不尽
清歌不尽 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:21

    This is good and simple example for implement it

    Click following link to get it https://github.com/nverinaud/NVSlideMenuController

    0 讨论(0)
  • 2021-01-02 14:34

    Just have a look

    https://github.com/BenHall/ios_facebook_style_navigation

    you will find many ways to do that. Select anyone as per your need.

    0 讨论(0)
  • 2021-01-02 14:38

    Facebook guys have done brilliant job in the new version of the app. The similar open source code can be found from here -

    It reveals technique behind doing split view for iPhone.

    Edit: Few other open source codes:

    Source 1
    Source 2
    Source 3
    Source 4
    Source 5
    Source 6
    Source 7
    Source 8
    Source 9
    Source 10
    Source 11

    0 讨论(0)
  • 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.

    0 讨论(0)
  • 2021-01-02 14:43

    NO there are no SDK available to do this. you can do this by two way.

    1. By using two UIViewController
    2. By using two UIView.

    I recommend second one because I have used it and working fine.

    For first approach you will find some example and demo on github.com.

    let me give you short idea how I have implemented it by using two UIView.

    Your all normal content will be in default UIView and slide controls will be on second view.

    By default normal UIView will be visible and slider UIView be at -x pos something like (-200,0,200,320) set this according to your need.

    When you click show/hide button it change its frame property so normal UIView slide right side 200 pt and slider UIView come in screen.

    Let me show u some code to hide/unhide:

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    view.frame = CGRectMake(250,
               view.frame.origin.y,
               view.frame.size.width,
               view.frame.size.height);;
    
    slideView.frame = CGRectMake(0, view.frame.origin.y, 250, view.frame.size.height);;
    
    [UIView commitAnimations];
    

    Parameter in CGRectMake can be anything according to what you want.

    To implement this make a subclass of UIView. and add UITableView if u want look like facebook.

    Update:

    While searching some new implementation I found a wonderful job on this concept by one developer. If anyone is thinking to add this feature than you must visit this once : MMDrawerController

    All the best

    0 讨论(0)
提交回复
热议问题