项目介绍:
项目简介
Interactive Side Menu
iOS交互滑动菜单,使用Swift编写。
它支持下列自定义信息:
动画持续时间
可见内容的宽度
内容规模
使用spring动画参数自定义
动画选项,类似动画曲线
安装
CocoaPods
pod ‘InteractiveSideMenu’
Carthage
github “handsomecode/InteractiveSideMenu”
使用方法
import InteractiveSideMenu
class HostViewController: MenuContainerViewController {
override func viewDidLoad() {
super.viewDidLoad()
menuViewController = self.storyboard!.instantiateViewController(withIdentifier: "NavigationMenu") as! MenuViewController
contentViewControllers = contentControllers()
selectContentViewController(contentViewControllers.first!)
}
private func contentControllers() -> [MenuItemContentViewController] {
var contentList = [MenuItemContentViewController]()
contentList.append(self.storyboard?.instantiateViewController(withIdentifier: "First") as! MenuItemContentViewController)
contentList.append(self.storyboard?.instantiateViewController(withIdentifier: "Second") as! MenuItemContentViewController)
return contentList
}
}
为了显示菜单你需要调用showMenu()方法,可以在MenuItemContentViewController类中获取.
import InteractiveSideMenu
class FirstViewController: MenuItemContentViewController {
@IBAction func didOpenMenu(_ sender: UIButton) {
showMenu()
}
}
要改变内容视图你需要选择所需内容控件并隐藏菜单。
let index = 2 // second menu item
guard let menuContainerViewController = self.menuContainerViewController else { return }
let contentController = menuContainerViewController.contentViewControllers[index]
menuContainerViewController.selectContentViewController(contentController)
menuContainerViewController.hideMenu()
需求
iOS 8.0+
Xcode 8.1+
Swift 3.0+
github地址:
https://github.com/handsomecode/InteractiveSideMenu