A simple view-based slide-in menu for iOS.
Swift 3.0
- Copy
PCLSlideInMenu.swift
to your project
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!
PCLSlideInMenu is licensed under the terms of the MIT License. For more details, please see the LICENSE file.