What is LCSlideMenu?
LCSlideMenu It's a powerful and easy to use slider menu.
Screencast from our Demo
Requirements
- iOS 11.2
- Xcode 9.2
- Swift 4.0.3+
Installation
CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:
$ gem install cocoapods
Just add the LCSlideMenu
folder to your project.
or use CocoaPods
with Podfile:
pod 'LCSlideMenu'
Swift 4.0.3:
platform :ios, '11.2'
target '<Your Target Name>' do
use_frameworks!
pod 'LCSlideMenu'
end
Then, run the following command:
$ pod install
Example:
import UIKit
import LCSlideMenu
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
example()
}
fileprivate func example() {
let titles = ["头条", "精选", "轻松一刻", "娱乐", "新时代", "手机","体育", "视频", "财经", "汽车","军事", "房产", "健康", "彩票", "搞笑"]
var controllers: [UIViewController] = []
for _ in 0 ..< titles.count {
let vc = UIViewController()
vc.view.backgroundColor = UIColor(red: CGFloat(arc4random() % 256) / 255, green: CGFloat(arc4random() % 256) / 255, blue: CGFloat(arc4random() % 256) / 255, alpha: 1)
addChildViewController(vc)
controllers.append(vc)
}
/* -- LCSlideMenu -- */
let slideMenu = LCSlideMenu(frame: CGRect(x: 0, y: 64, width: view.frame.width, height: 40), titles: titles, childControllers: controllers)
slideMenu.indicatorType = .stretch
slideMenu.titleStyle = .gradient
slideMenu.selectedColor = .red
slideMenu.unSelectedColor = .black
slideMenu.indicatorView.backgroundColor = .red
view.addSubview(slideMenu)
}
}