Switch

用 Swift 实现的一个 iOS 开关控件,完全支持 Interface Builder。「💊 An iOS switch control implemented in Swift with full Interface Builder support」

Github stars Tracking Chart

'   :::===  :::  ===  === ::: :::==== :::===== :::  ===
'   :::     :::  ===  === ::: :::==== :::      :::  ===
'    =====  ===  ===  === ===   ===   ===      ========
'       ===  ===========  ===   ===   ===      ===  ===
'   ======    ==== ====   ===   ===    ======= ===  ===
'                                                              

Switch

CI Status
GitHub issues
Codecov
Documentation

GitHub release
Platform
License

Carthage

CocoaPods
CocoaPods downloads

Description

An iOS switch control implemented in Swift with full Interface Builder support.

To run the demo project:

pod try RoundedSwitch

Switch

Switch

Usage

Either config the switch in the Interface Builder or programatically as follow:

import Switch
...
let mySwitch = Switch()
mySwitch.leftText = "Windows"
mySwitch.rightText = "Mac"
mySwitch.rightSelected = true
mySwitch.tintColor = UIColor.purple
mySwitch.disabledColor = mySwitch.tintColor.withAlphaComponent(0.4)
mySwitch.backColor = mySwitch.tintColor.withAlphaComponent(0.05)
mySwitch.sizeToFit()
mySwitch.addTarget(self, action: #selector(ViewController.switchDidChangeValue(_:)), for: .valueChanged)

Please note that the module name is Switch. However, when installed with CocoaPods, it is RoundedSwitch.

Please see the Reference Documentation for details.

Installation

Carthage

Add the line below to your Cartfile:

github "T-Pham/Switch"

CocoaPods

Add the line below to your Podfile:

pod 'RoundedSwitch'

Manually

Add the file Switch.swift to your project. You are all set.

Compatibility

From version 2.0.0, Swift 3 syntax is used. If your project is still using Swift version 2, please use a UITextField-Navigation version prior to 2.0.0.

Podfile

pod 'RoundedSwitch', '~> 1.0.3'

or Cartfile

github "T-Pham/Switch" ~> 1.0.3

License

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

Main metrics

Overview
Name With OwnerT-Pham/Switch
Primary LanguageSwift
Program languageSwift (Language Count: 3)
Platform
License:MIT License
所有者活动
Created At2016-08-29 07:25:21
Pushed At2021-07-09 22:39:09
Last Commit At2021-07-09 15:31:37
Release Count9
Last Release Name3.0.0 (Posted on )
First Release Name1.0.0 (Posted on )
用户参与
Stargazers Count148
Watchers Count12
Fork Count26
Commits Count27
Has Issues Enabled
Issues Count4
Issue Open Count0
Pull Requests Count1
Pull Requests Open Count0
Pull Requests Close Count0
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private