Skip to content

pinchih/PCLSlideInMenu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PCLSlideInMenu

A simple view-based slide-in menu for iOS.

Language

Swift 3.0

Installation

  • Copy PCLSlideInMenu.swift to your project

Usage

The following steps shows how to setup a basic PCLSlideInMenu.

  • Make your viewcontroller confirmed to the PCLSlideInMenuDataSource and PCLSlideInMenuDelegate protocol.

  • Assign your PCLSlideInMenu's delegate and dataSource to the controller.

// In your view controller, 
myMenu.dataSource = self
myMenu.delegate = self
myMenu.animation = .slideIn
  • Inplement the PCLSlideInMenuDataSource method
// For example
func menuItemCount() -> Int {
  return 3
}

func menuItemSpacing() -> CGFloat {
  return 60.0
}
    

func menuItemAt(Index: Int) -> MenuItemInfo {
        
  let menuItem1 = MenuItemInfo(iconImage: UIImage(named: "demo0_default")!, iconWidthAndHeight: 50,backgroundColor:UIColor.clearColor())
  let menuItem2 = MenuItemInfo(iconImage: UIImage(named: "demo1_default")!, iconWidthAndHeight: 50,backgroundColor:UIColor.clearColor())
  let menuItem3 = MenuItemInfo(iconImage: UIImage(named: "demo2_default")!, iconWidthAndHeight: 50,backgroundColor:UIColor.clearColor())
        
  /* 
        
 // If you're using the rotate animation, please rotate your original image by 90 degree clockwise to get the best effect
         
 let menuItem1 = MenuItemInfo(iconImage: UIImage(named: "demo0")!, iconWidthAndHeight: 50,backgroundColor:UIColor.clearColor())
 let menuItem2 = MenuItemInfo(iconImage: UIImage(named: "demo1")!, iconWidthAndHeight: 50,backgroundColor:UIColor.clearColor())
 let menuItem3 = MenuItemInfo(iconImage: UIImage(named: "demo2")!, iconWidthAndHeight: 50,backgroundColor:UIColor.clearColor())
  */
  
  return [menuItem1,menuItem2,menuItem3][Index]
        
}

  • Inplement the PCLSlideInMenuDelegate method
func menuItemClickedAt(Index: Int) {
    
    // Do something to handle menu click event  
    // For example
    print(Index)
        
}

  • Done!

Demo

Default animation

Alt Text

Rotate animation

Alt Text

License

PCLSlideInMenu is licensed under the terms of the MIT License. For more details, please see the LICENSE file.

About

A simple view-based slide in menu for iOS.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages