kiddhmh / MHSwitch

动画效果的开关

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MHSwitch

动画效果的开关;

This is a funny switch for iOS

Thank lilei644 for providing inspiration


Preview 预览

MHSwitchDemo

Installation  

  • Common
Add "MHSwitch" files to your Project   // 直接导入“MHSwitch”文件夹到项目中 (后面会支持cocoaPod和carthge导入)

Usage  用法

  • Init  初始化
let mhSwitch = MHSwitch.init(frame: CGRect(x: 100, y: 100, width: 120, height: 60))
view.addSubview(mhSwitch)
  • Reset Base Property  重设基本属性
mhSwitch.onColor = .blue    // switch is open color   开关打开的颜色
mhSwitch.offColor = .gray    // switch is close color    开关关闭的颜色
mhSwitch.faceColor = .whiteColor    // switch face color    圆脸的颜色
mhSwitch.animationDuration = 1.2    // switch open or close animation time    开关的动画时间

mhSwitch.isOn = true                     // set on and off     设置开关
mhSwitch.setOn(isOn: true, animated: true)
  • delegate  代理监听
mhSwitch.delegate = self

func valueDidChanged(mhSwitch: MHSwitch, isOn: Bool) {
        print("stop\(isOn)")
    }
    
func didTapMHSwitch(mhSwitch: MHSwitch) {
        print("didStart")
    }
    
func animationDidStopForMHSwitch(mhSwitch: MHSwitch) {
        print("didStop")
    }
  • support xib and storyboard 支持xib和storyboard MHSwitchForXib

About

动画效果的开关


Languages

Language:Swift 100.0%