Latest 1.4.0
Homepage https://github.com/tamanyan/SwiftPageMenu
License MIT
Platforms ios 10.0, requires ARC
Authors

SwiftPageMenu

Carthage compatible

1
2
3
4

Customizable Page Menu ViewController in Swift

Features

  • Infinite Page Menu
  • Top / Bottom Position Menu
  • Custom Color Menu
  • Round Rect / Underline Page Cursor

This framework is reference by msaps/Pageboy, rechsteiner/Parchment, EndouMari/TabPageViewController

Requirements

  • iOS 10.0+
  • Swift 4.2+

How to use

DataSource

SwiftPageMenu supports adding your own custom data sources.

@objc public protocol PageMenuControllerDataSource: class {
    /// The view controllers to display in the page menu view controller.
    func viewControllers(forPageMenuController pageMenuController: PageMenuController) -> [UIViewController]

    /// The view controllers to display in the page menu view controller.
    func menuTitles(forPageMenuController pageMenuController: PageMenuController) -> [String]

    /// The default page index to display in the page menu view controller.
    func defaultPageIndex(forPageMenuController pageMenuController: PageMenuController) -> Int
}

Delegate

SwiftPageMenu give you the events below code.

@objc public protocol PageMenuControllerDelegate: class {
    /// The page view controller will begin scrolling to a new page.
    @objc optional func pageMenuController(_ pageMenuController: PageMenuController,
                                           willScrollToPageAtIndex index: Int,
                                           direction: PageMenuNavigationDirection)

    /// The page view controller scroll progress between pages.
    @objc optional func pageMenuController(_ pageMenuController: PageMenuController,
                                           scrollingProgress progress: CGFloat,
                                           direction: PageMenuNavigationDirection)

    /// The page view controller did complete scroll to a new page.
    @objc optional func pageMenuController(_ pageMenuController: PageMenuController,
                                           didScrollToPageAtIndex index: Int,
                                           direction: PageMenuNavigationDirection)

    /// The menu item of page view controller are selected.
    @objc optional func pageMenuController(_ pageMenuController: PageMenuController,
                                           didSelectMenuItem index: Int,
                                           direction: PageMenuNavigationDirection)
}

Customization

It is easy to customize SwiftPageMenu. All customization is handled by the PageMenuOptions protocol.
You can create own struct that conforms to this protocol.

import SwiftPageMenu

struct RoundRectPagerOption: PageMenuOptions {
    var isInfinite: Bool = false

    var tabMenuPosition: TabMenuPosition = .top

    var menuItemSize: PageMenuItemSize {
        return .sizeToFit(minWidth: 80, height: 30)
    }

    var menuTitleColor: UIColor {
        return .white
    }

    var menuTitleSelectedColor: UIColor {
        return UIColor(red: 3/255, green: 125/255, blue: 233/255, alpha: 1)
    }

    var menuCursor: PageMenuCursor {
        return .roundRect(rectColor: .white, cornerRadius: 10, height: 22)
    }

    var font: UIFont {
        return .systemFont(ofSize: UIFont.systemFontSize)
    }

    var menuItemMargin: CGFloat {
        return 8
    }

    var tabMenuBackgroundColor: UIColor {
        return UIColor(red: 3/255, green: 125/255, blue: 233/255, alpha: 1)
    }

    var tabMenuContentInset: UIEdgeInsets {
        return UIEdgeInsets(top: 0, left: 4, bottom: 0, right: 4)
    }

    public init(isInfinite: Bool = false, tabMenuPosition: TabMenuPosition = .top) {
        self.isInfinite = isInfinite
        self.tabMenuPosition = tabMenuPosition
    }
}

Carthage

To integrate SwiftPageMenu into your Xcode project using Carthage, specify it in your Cartfile:

github "tamanyan/SwiftPageMenu"

CocoaPods

target 'MyApp' do
  use_frameworks!
  pod 'Swift_PageMenu', '~> 1.4'
end

License

MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "Swift_PageMenu",
    "version": "1.4.0",
    "summary": "Customizable Page Tab Menu Controller ud83dudc4d",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "homepage": "https://github.com/tamanyan/SwiftPageMenu",
    "authors": {
        "Taketo Yoshida": "[email protected]"
    },
    "source": {
        "git": "https://github.com/tamanyan/SwiftPageMenu.git",
        "tag": "1.4.0"
    },
    "platforms": {
        "ios": "10.0"
    },
    "requires_arc": true,
    "source_files": "Sources/**/*.{swift}",
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This