Latest 0.2.0
Homepage https://github.com/William-Weng/WWSegmentControl
License MIT
Platforms ios 10.0
Frameworks UIKit
Authors

一個自訂有QQ動畫的SegmentControl

Swift 4.0 Version Platform License

一個自訂的SegmentControl (上傳至Cocoapods)

使用範例

IBOutlet

import UIKit
import WWSegmentControl

class ViewController: UIViewController {

    @IBOutlet weak var myLabel: UILabel!
    @IBOutlet weak var myUIView: UIView!
    @IBOutlet weak var mySegmentControl: WWSegmentControl!

    override func viewDidLoad() {
        super.viewDidLoad()

        initWithIBOutlet()
        initWithFrame()
        initWithAutolayout(with: myUIView)
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}

extension ViewController {

    /// 使用IBOutlet
    private func initWithIBOutlet() {
        mySegmentControl.delegate = self
    }

    /// 使用Frame
    private func initWithFrame() {
        let mySegmentControl = WWSegmentControl.init(frame: CGRect.init(x: 50, y: 250, width: 200, height: 50))
        mySegmentControl.countSetting(3)
        mySegmentControl.titleSetting(["A", "B", "C"])
        view.addSubview(mySegmentControl)
    }

    /// 使用Autolayout
    private func initWithAutolayout(with view: UIView) {
        let mySegmentControl = WWSegmentControl()
        mySegmentControl.countSetting(3)
        mySegmentControl.titleSetting(["あ", "い", "う"])
        mySegmentControl.autolayoutSetting(to: view)
    }
}

extension ViewController: WWSegmentControlDelegate {

    /// 現在選到哪一個
    func wwSegmentControl(_ wwSegmentControl: WWSegmentControl, selectedItemAt index: Int, for button: UIButton) {
        myLabel.text = button.titleLabel?.text
        print(index)
    }
}

Latest podspec

{
    "name": "WWSegmentControl",
    "version": "0.2.0",
    "summary": "WWSegmentControl is a like UISegmentedControl's view with jelly animation. (u4e00u500bu81eau8a02u6709QQu52d5u756bu7684SegmentControl)",
    "homepage": "https://github.com/William-Weng/WWSegmentControl",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "u7fc1u79b9u658c(William.Weng)": "[email protected]"
    },
    "platforms": {
        "ios": "10.0"
    },
    "ios": {
        "vendored_frameworks": "WWSegmentControl.framework"
    },
    "source": {
        "git": "https://github.com/William-Weng/WWSegmentControl.git",
        "tag": "0.2.0"
    },
    "frameworks": "UIKit"
}

Pin It on Pinterest

Share This