Menu popover from bottom to top sliding iOS swift

 Problem:

I want to show popover from bottom to top sliding like material design.How can i achieve that?

Solution:

First need to add expanding menu in pods and install it.Then proceed with the below code.

import ExpandingMenu


    fileprivate func configMenuButton() {

          let menuButtonSize: CGSize = CGSize(width: 50.0, height: 50.0)

           menuButton = ExpandingMenuButton(frame: self.myBtn.frame, image:"ImgName", rotatedImage:"ImgName")

          self.view.addSubview(menuButton)

          self.view.bringSubviewToFront(menuButton)

        menuButton.center = self.myBtn.center


          var menuItems:[ExpandingMenuItem] = []

          for i in 0..<OptionsList.allCases.count {

              let menuItem = OptionsList(rawValue: i)

              let item1 = ExpandingMenuItem(size: menuButtonSize, title: menuItem?.title, image: (menuItem?.image)!, highlightedImage: (menuItem?.image)!, backgroundImage:"img", backgroundHighlightedImage: "imgSelected") { () -> Void in

                  self.didOptionSelection(index: i)

              }

              item1.tintColor = (menuItem?.bgColor)!

              menuItems.append(item1)

          }

          menuButton.addMenuItems(menuItems)

        menuButton.clipsToBounds = true

      }


//While click on menu the below function will be called

func didOptionSelection(index:Int) {
}


You can easily achieve that with above code.

Comments

Popular posts from this blog

store cgpoint in userdefaults iOS swift

libc++abi: terminating due to uncaught exception of type NSException iOS swift