SwipeMenuViewController
This is swipable menu framework including SwipeMenuView and SwipeMenuViewController. It is designed to resembling simple UIKit interface.
从这里下载
请按你喜欢当明星
Here are some style demos and codes using SwipeMenuView.
Segmented style@IBOutlet weak var swipeMenuView: SwipeMenuView! { didSet { swipeMenuView.delegate = self swipeMenuView.dataSource = self var options: SwipeMenuViewOptions = .init() options.tabView.style = .segmented options.tabView.underlineView.backgroundColor = UIColor.customUnderlineColor options.tabView.itemView.textColor = UIColor.customTextColor options.tabView.itemView.selectedTextColor = UIColor.customSelectedTextColor swipeMenuView.reload(options: options) } }Flexible style@IBOutlet weak var swipeMenuView: SwipeMenuView! { didSet { swipeMenuView.delegate = self swipeMenuView.dataSource = self var options: SwipeMenuViewOptions = .init() options.tabView.style = .flexible options.tabView.margin = 8.0 options.tabView.underlineView.backgroundColor = UIColor.customUnderlineColor options.tabView.backgroundColor = UIColor.customBackgroundColor options.tabView.underlineView.height = 3.0 options.tabView.itemView.textColor = UIColor.customTextColor options.tabView.itemView.selectedTextColor = .white options.tabView.itemView.margin = 10.0 options.contentScrollView.backgroundColor = UIColor.customBackgroundColor swipeMenuView.reload(options: options) } }InstallationCocoaPodsSwipeMenuViewController is available through CocoaPods. To install it, add the following line to your Podfile :
pod ‘SwipeMenuViewController’CarthageSwipeMenuViewController is also available through Carthage. Add the following line to your Cartfile :
github “yysskk/SwipeMenuViewController”UsageSwipeMenuView1) Add the files listed in the installation section to your project
2) Import SwipeMenuViewController module to your CustomViewController class
import SwipeMenuViewController3) Add SwipeMenuView to CustomViewController , then set dataSource and delegate, options if you need for it
class CustomViewController: UIViewController { @IBOutlet weak var swipeMenuView: SwipeMenuView! override func viewDidLoad() { super.viewDidLoad() swipeMenuView.dataSource = self swipeMenuView.delegate = self let options: SwipeMenuViewOptions = .init() swipeMenuView.reloadData(options: options) } }4) Conform your CustomViewController to SwipeMenuViewControllerDelegate optional protocol.
extension CustomViewController: SwipeMenuViewControllerDelegate { // MARK - SwipeMenuViewControllerDelegate func swipeMenuView(_ swipeMenuView: SwipeMenuView, willChangeIndexFrom fromIndex: Int, to toIndex: Int) { // Codes } func swipeMenuView(_ swipeMenuView: SwipeMenuView, didChangeIndexFrom fromIndex: Int, to toIndex: Int) { // Codes } }5) Conform your CustomViewController to SwipeMenuViewControllerDataSource protocol.
extension CustomViewController: SwipeMenuViewControllerDataSource { //MARK - SwipeMenuViewControllerDataSource func numberOfPages(in swipeMenuView: SwipeMenuView) -> Int { return array.count } func swipeMenuView(_ swipeMenuView: SwipeMenuView, titleForPageAt index: Int) -> String { return array[index] } func swipeMenuView(_ swipeMenuView: SwipeMenuView, viewControllerForPageAt index: Int) -> UIViewController { let vc = ContentViewController() return vc } }SwipeMenuViewController1) Check SwipeMenuView section 1) ~ 2)
2) Use SwipeMenuViewController classes
class CustomViewController: SwipeMenuViewController { }3) Conform your CustomViewController to override SwipeMenuViewDelegate methods and SwipeMenuViewDataSource methods if you need.
extension CustomViewController { // MARK: - SwipeMenuViewDelegate override func swipeMenuView(_ swipeMenuView: SwipeMenuView, willChangeIndexFrom fromIndex: Int, to toIndex: Int) { // Codes } override func swipeMenuView(_ swipeMenuView: SwipeMenuView, didChangeIndexFrom fromIndex: Int, to toIndex: Int) { // Codes } // MARK - SwipeMenuViewDataSource open override func numberOfPages(in swipeMenuView: SwipeMenuView) -> Int { return array.count } override func swipeMenuView(_ swipeMenuView: SwipeMenuView, titleForPageAt index: Int) -> String { return array[index] } override func swipeMenuView(_ swipeMenuView: SwipeMenuView, viewControllerForPageAt index: Int) -> UIViewController { let vc = ContentViewController() return vc } }RequirementsXcode 8.0+
Swift 3.0+
CreatorYusuke MorishitaGithub
,论文,开题报告