Latest 0.0.3
Homepage https://github.com/dragonetail/SwiftPagingTabView
License MIT
Platforms ios 9.0
Dependencies PureLayout
Authors

Version
Platform
Swift Version
Swift Version
License

SwiftPagingTabView

Example

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

Requirements

  • Swift 4.2
  • iOS 9.0+
  • Xcode 10.1

Installation

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

platform :ios, '11.0'
use_frameworks!
pod 'SwiftPagingTabView'

To get the full benefits import SwiftPagingTabView wherever you import UIKit

import UIKit
import SwiftPagingTabView

Usage example

Programmatically

import UIKit
import SwiftPagingTabView

class ViewController: UIViewController {

    public lazy var pagingTabView: PagingTabView = {
        let pagingTabView: PagingTabView = PagingTabView()
        pagingTabView.config = PagingTabViewConfig()
        pagingTabView.delegate = self
        pagingTabView.datasource = self

        return pagingTabView
    }()

    override func viewDidLoad() {
        super.viewDidLoad()

        self.view.addSubview(pagingTabView)

        pagingTabView.reloadAndSetup()
    }

extension ViewController: PagingTabViewDelegate {
    func pagingTabView(pagingTabView: PagingTabView, toIndex: Int) {
        print("Switch to paging tab view: (toIndex)")
    }

    func reconfigure(pagingTabView: PagingTabView) {
        pagingTabView.tabButtons.forEach { (tabButton) in
            tabButton.configure(config: TabButtonConfig())
        }
    }
}
extension ViewController: PagingTabViewDataSource {
    func segments(pagingTabView: PagingTabView) -> Int {
        return 4
    }

    func tabTitle(pagingTabView: PagingTabView, index: Int) -> (image: UIImage?, title: String?) {
        if commandView.isEnableImageTitle {
            return (image: UIImage(named: "menu"),
                    title: "TAB标签_" + String(index))
        } else {
            return (image: nil,
                    title: "TAB标签_" + String(index))
        }
    }

    func tabView(pagingTabView: PagingTabView, index: Int) -> UIView {
        if index == 0 {
            return commandView
        } else {
            let view = UILabel()
            view.backgroundColor = UIColor.white
            view.text = "View " + String(index)
            view.textAlignment = .center
            return view
        }
    }
}

Author

dragonetail, [email protected]

License

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

Latest podspec

{
    "name": "SwiftPagingTabView",
    "version": "0.0.3",
    "summary": "Paging Tab View implement in swift4.2.",
    "description": "Paging Tab View implement in swift4.2 using ScrollView and configurable design.",
    "homepage": "https://github.com/dragonetail/SwiftPagingTabView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "dragonetail": "[email protected]"
    },
    "source": {
        "git": "https://github.com/dragonetail/SwiftPagingTabView.git",
        "tag": "0.0.3"
    },
    "platforms": {
        "ios": "9.0"
    },
    "swift_version": "4.2",
    "source_files": "Source/**/*",
    "dependencies": {
        "PureLayout": [
            "~> 3.1.4"
        ]
    }
}

Pin It on Pinterest

Share This