HTCustomSwitch 1.0.4

HTCustomSwitch 1.0.4

HungTran 维护。



  • HungTran

HTCustomSwitch

用于自定义 UISwitch 的简单框架。

DEMO

默认

自定义

安装

Cocoapods

如有必要,请安装 Cocoapods。

$ gem install cocoapods

在您的 Podfile 中添加 HTCustomSwitch

use_frameworks!

pod 'HTCustomSwitch'

然后,运行以下命令。

$ pod install

手册

只需将HTCustomSwitch文件复制到您的项目中即可。就这么简单。

用法

初始化

首先导入HTCustomSwitch

import HTCustomSwitch

然后使用初始化器。

let myCustomUISwitch = HTCustomSwitch(frame: CGRect(x: 200, y: 200, width: 80, height: 50))

或者,您可以通过将任何UIView的类更改为HTCustomSwitch来使用Storyboard创建它。

属性

  • isOn
myCustomUISwitch.isOn = 'Bool'
  • 开启球大小
myCustomUISwitch.onBallSize = 'CGFloat'
  • 开启球颜色
myCustomUISwitch.onBallColor = 'UIColor'
  • 开启球边框颜色
myCustomUISwitch.onBallBorderColor = 'UIColor'
  • 开启容器颜色
myCustomUISwitch.onColorContainer = 'UIColor'
  • 开启容器边框颜色
myCustomUISwitch.onColorContainer = 'UIColor'
  • 关闭球大小
myCustomUISwitch.offBallSize = 'CGFloat'
  • 关闭球颜色
myCustomUISwitch.offBallColor = 'UIColor'
  • 关闭球边框颜色
myCustomUISwitch.offBallBorderColor = 'UIColor'
  • 关闭容器颜色
myCustomUISwitch.offColorContainer = 'UIColor'
  • 关闭容器边框颜色
myCustomUISwitch.offColorContainer = 'UIColor'
  • Storyboard

使用

  • 将此行代码添加到您的viewDidLoad()
myCustomUISwitch.delegate = self
  • 使您的ViewControllerHTCustomSwitchDelegate继承
extension ViewController: HTCustomSwitchDelegate {

    func valueChanged(sender: HTCustomSwitch) {
        print(sender.isOn)
    }
}

许可

在MIT许可下发布。详细信息请参阅LICENSE。