Skip to content
Tabbed page view controller.
Swift Ruby
Branch: master
Clone or download
IgnorantCoder add badge. (#4)
* add badge.

* reduce argument.

* Fix namespace length.

* Fix namespace length.
Latest commit b946914 Dec 20, 2017
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example
HDTabbedPageView/Classes
.gitignore
.swift-version
.travis.yml
HDTabbedPageView.podspec
LICENSE
README.md
_Pods.xcodeproj

README.md

HDTabbedPageView

CI Status Version License Platform codebeat badge

Description

Inspired by TabPageViewController.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

You can use it with inheritance of HDTabbedPageViewController and implementation of HDTabbedPageViewControllerimplementation and HDTabbedPageViewControllerStyle.

It's very easy as the following.

class ViewController: HDTabbedPageViewController, HDTabbedPageViewControllerDataSource, HDTabbedPageViewControllerStyle {
    //MARK:- Sub components.
    private let roundedRect = RoundedRect(color: .orange, padding: 5)

    //MARK:- Life cycle events.
    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.backgroundColor = .white

        self.dataSource = self
        self.style = self
        self.indicator = self.roundedRect
    }

    override func viewWillLayoutSubviews() {
        super.viewWillLayoutSubviews()
        self.view.frame = UIScreen.main.bounds
    }

    //MARK:- HDTabbedPageViewControllerDataSource
    var controllers: [UIViewController] = [
        ViewController.createSampleViewController("Red", .red),
        ViewController.createSampleViewController("Cyan", .cyan),
        ViewController.createSampleViewController("Green", .green),
    ]

    //MARK:- HDTabbedPageViewControllerStyle
    var textColorOfTab: UIColor {
        get {
            return .black
        }
    }

    //MARK:- Helper
    private static func createSampleViewController(_ title: String,
                                                   _ color: UIColor) -> UIViewController
    {
        let controller = UIViewController()
        controller.title = title
        controller.view.backgroundColor = color
        return controller
    }
}

Customize

You can easy to customize this library.

HDTabbedPageViewControllerDataSource

There are two optional interfaces except controllers.

  • count : The number of data source. It is the default implementation to return controllers.count.
  • titles : The titles of controllers. It is the default implementation to return titles of controllers.

HDTabbedPageViewControllerStyle

There are optional interfaces except textColorOfTab.

  • textSizeOfTab : The color of tab of text.
  • heightOfTab : The height of tab.(default 45)
  • topGapOfTab : The gap of the top of tab.(default 0)
  • bottomGapOfTab : The gap of the bottom of tab.(default 0)

HDTabbedPageViewIndicator

This is the protocol for indicator. When you create implementation of this protocol, you should create as subclass of UIView.

There are two reference implementation, please refer them if you want to implement your customize one. Those are Underline and RoundedRect.

Installation

HDTabbedPageView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'HDTabbedPageView'

Author

Handii, Inc. github@handii.co.jp

License

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

You can’t perform that action at this time.