' :::=== ::: === === ::: :::==== :::===== ::: ===
' ::: ::: === === ::: :::==== ::: ::: ===
' ===== === === === === === === ========
' === =========== === === === === ===
' ====== ==== ==== === === ======= === ===
'
切换
说明
使用 Swift 实现的 iOS 切换控件,完全支持 Interface Builder。
运行演示项目
pod try RoundedSwitch
使用方法
您可以在 Interface Builder 中配置切换,或者按照以下方式进行编程配置
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)
请注意,模块名为 Switch
。然而,当使用 CocoaPods 安装时,它为 RoundedSwitch
。
请参阅参考文档以获取详细信息。
安装
Carthage
在您的 Cartfile 中添加以下行
github "T-Pham/Switch"
CocoaPods
在您的 Podfile 中添加以下行
pod 'RoundedSwitch'
手动操作
将文件 Switch.swift
添加到您的项目。您已经设置完毕。
兼容性
从版本 2.0.0 开始,使用 Swift 3 语法。如果您的项目仍在使用 Swift 2 版本,请使用低于 2.0.0 的 UITextField-Navigation 版本。
Podfile
pod 'RoundedSwitch', '~> 1.0.3'
或 Cartfile
github "T-Pham/Switch" ~> 1.0.3
许可证
Switch 在 MIT 许可证下可用。关于更多信息,请参阅 LICENSE 文件。