Latest 0.0.2
Homepage https://github.com/hkm5558/KMPageMenu
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit
Authors

CocoaPods

Installation with CocoaPods

CocoaPods is a dependency manager for Objective-C, which automates and simplifies the process of using 3rd-party libraries. You can install it with the following command:

$ gem install cocoapods

Podfile

To integrate KMPageMenu into your Xcode project using CocoaPods, specify it in your Podfile:

In your Podfile

pod 'KMPageMenu'

Then, run the following command:

$ pod install

Requirements

This library requires iOS 8.0+

Architecture

  • KMPageMenu
  • KMPageMenuEnum
  • KMPagingViewController

Usage

    //首先把 菜单 和 分页视图控制器 添加到视图上
    let menu = KMPageMenu(frame: CGRect(x: 0, y: 40, width: width, height: 44), titles: titles)
    m.style.titleFont = UIFont.systemFont(ofSize: 14)
    view.addSubview(menu)

    let page = KMPagingViewController(viewControllers: viewControllers)

    page.view.frame = CGRect(x: 0, y: menu.frame.maxY, width: width, height: view.frame.height - menu.frame.maxY)
    self.addChildViewController(page)
    page.didMove(toParentViewController: self)
    self.view.addSubview(page.view)

    // 菜单下标改变的回调
    menu.valueChange = { [weak self] index in
        self?.page.pagingToViewController(at: index)
    }

    // KMPageMenu 控件继承于 UIControl 所以也可以用监听 valueChanged 的方式
    menu.addTarget(self, action: #selector(menuValueChange(sender:)), for: .valueChanged)

    // 分页控制器切换完成的回调
    page.didFinishPagingCallBack = { [weak self] (currentViewController, currentIndex)in
        self?.menu.setSelectIndex(index: currentIndex, animated: true)
    }

    // KMPagingViewController 同时也提供了代理的回调
    // KMPagingViewControllerDelegate

    page.delegate = self

    func pagingController(_ pagingController: KMPagingViewController, didFinish currentViewController: UIViewController, currentIndex: Int) {

        print("selectIndex == (currentIndex)")

    }

Gif

Author

hkm5558, [email protected]

License

KMPageMenu is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "KMPageMenu",
    "version": "0.0.2",
    "summary": "u5206u9875u83dcu5355 u6ed1u52a8u5207u6362u9875u9762 u5728u5f88u591aAPPu4e2du90fdu53efu4ee5u770bu5230u6781u5176u7c7bu4f3cu7684u754cu9762",
    "description": "u5206u9875u83dcu5355 u6ed1u52a8u5207u6362u9875u9762 u5728u5f88u591aAPPu4e2du90fdu53efu4ee5u770bu5230u6781u5176u7c7bu4f3cu7684u754cu9762nu652fu6301pod",
    "swift_version": "4.0",
    "platforms": {
        "ios": "8.0"
    },
    "requires_arc": true,
    "homepage": "https://github.com/hkm5558/KMPageMenu",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "hkm5558": "[email protected]"
    },
    "source": {
        "git": "https://github.com/hkm5558/KMPageMenu.git",
        "tag": "0.0.2"
    },
    "source_files": "KMPageMenu/Classes/**/*.*",
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This