Latest 0.1.1
Homepage https://github.com/summertian4/SlideTabKit
License MIT
Platforms ios 8.0, requires ARC
Dependencies SnapKit, FrameKit
Authors

Introduction

中文介绍

SlideTabKit is a simple and easy to use tools of slide tab.

"Slide Tab Tool" and "Paging tool" can be used in combination or split.

Install

pod 'SlideTabKit'

Example

Use the SlideTabKit

var slideTabKit: SlideTabKit = SlideTabKit()
var vcs: [UIViewController] = []
var titles: [String] = ["Tab 0", "Tab 1", "Tab 2", "Tab 3"]

override func viewDidLoad() {
    super.viewDidLoad()

    for _ in 0 ..< 4 {
        let vc = UIViewController()
        vc.view.backgroundColor = UIColor.randomColor
        vcs.append(vc)
    }
    view.addSubview(slideTabKit.slideTabBar)
    slideTabKit.slideTabBar.snp.makeConstraints { (make) in
        make.top.equalTo(topLayoutGuide.snp.bottom)
        make.left.right.equalTo(view)
        make.height.equalTo(40)
    }
    slideTabKit.slideTabBar.resetting(titles: titles)

    view.addSubview(slideTabKit.slideScrollView)
    slideTabKit.slideScrollView.snp.makeConstraints { (make) in
        make.top.equalTo(slideTabKit.slideTabBar.snp.bottom)
        make.left.right.bottom.equalTo(view)
    }
    slideTabKit.slideScrollView.resetting(childViews: vcs.map({ (vc) -> UIView in
        return vc.view
    }))
}

Use SlideTabBar alone


var slideTabBar0: SlideTabBar = SlideTabBar()

override func viewDidLoad() {
    super.viewDidLoad()

    // 设置 slideTabBar
    self.view.addSubview(slideTabBar0)
    // 其他属性设置完毕后调用 resetting
    slideTabBar0.resetting(titles: ["Tab 1", "Tab 2", "Tab 3", "Tab 4"])
    slideTabBar0.delegate = self

    slideTabBar0.snp.makeConstraints { (make) in
        make.top.equalTo(self.topLayoutGuide.snp.bottom)
        make.left.right.equalTo(self.view)
        make.height.equalTo(40)
    }
}

In addition to using text to initialize the style, also support custom style.

Use SlideScrollView alone

var vcs: [UIViewController] = []

override func viewDidLoad() {
    super.viewDidLoad()

    for _ in 0 ..< 4 {
        let vc = UIViewController()
        addChildViewController(vc)
        vcs.append(vc)

        vc.view.backgroundColor = UIColor.randomColor
    }

    self.view.addSubview(slideScrollView)
    let views = vcs.map { (viewController) -> UIView in
        return viewController.view
    }
    slideScrollView.resetting(childViews: views)
    slideScrollView.delegate = self
    slideScrollView.snp.remakeConstraints { (make) in
        make.edges.equalTo(self.view)
    }
}

Demo

It is recommended to download the Demo to see how to use SlideTabKit.

Feature

  • [x] "Slide Tab Tool" and "Paging tool" used in combination
  • [x] Use SlideTabBar alone
  • [x] Use paging tool alone
  • [ ] The text on the tab bar fades

License

SlideTabKit use GNU GENERAL PUBLIC LICENSE Version 3

Feedback

If there are any suggestions, pleas send an email to [email protected], and also welcome to my blog to discuss. Learning together~

Latest podspec

{
    "name": "SlideTabKit",
    "version": "0.1.1",
    "summary": "Simple and easy to use tools of slide tab / u7b80u5355u6613u7528u7684u6ed1u52a8u6807u7b7eu680fu5de5u5177",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "homepage": "https://github.com/summertian4/SlideTabKit",
    "source": {
        "git": "https://github.com/summertian4/SlideTabKit.git",
        "tag": "0.1.1"
    },
    "source_files": "SlideTabKit/**/*",
    "requires_arc": true,
    "platforms": {
        "ios": "8.0"
    },
    "dependencies": {
        "SnapKit": [
            "~> 3.2.0"
        ],
        "FrameKit": [
            "~> 0.1.0"
        ]
    },
    "authors": {
        "u5c0fu9c7cu5468u51ccu5b87": "[email protected]"
    },
    "social_media_url": "http://zhoulingyu.com",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This