AnimatedSwitch

UISwitch which paints over the parent view with the color in Swift.

  • 所有者: alsedi/AnimatedSwitch
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

AnimatedSwitch

Swift 4
InterfaceBuilder Designable
Twitter
Blog

Swift subclass of the UISwitch which paints over the parent view with the color if switch is turned on and returns original superview background color if switch is off.

Inspired by concept from this Dribbble

Screenshot

AnimatedSwitch

Requirements

  • Swift 3.2
  • iOS 9.3+
  • Xcode 7.3+

Installation

Copy AnimatedSwitch.swiftto your project. Copy file if needed.

Usage

AnimatedSwitch adds nice material-design-like animation to your UISwitch.

AnimatedSwitch uses custom color for state on and superview background color for state off

When activated fills super view area with circle shape of specific color

How to create

Programatically

let switch = AnimatedSwitch()

Storyboard and XIB

  1. Drap and drop a new UISwitch
  2. Set the class of the UISwitch to AnimatedSwitch
  3. Set color for the switch
  4. Set other parameters

Interfacebuilder

Configurable properties (in code and in Interface Builder)

All regular UISwitch
  1. color animation color for on state (off state uses superview.backgroundColor). Default .clearColor()
  2. animationDuraton how long AnimatedSwitch will draw circle to fill the superview frame. Default 0.25
  3. startRadius circle radius that will be shown on screen without animation. Default 15 (to fit UISwitch size)
  4. borderColor border color for on state. Default .colorWhite
  5. showBorder should border appear around UISwitch for on state. Default true
  6. shape filling shape: .Round, .Star, .Dimond or .Cusom(UIBezierPath). Default .Round (NB! Can be set in code only)

Callbacks

Animation started

let switch = AnimatedSwitch()
switch.animationDidStart = {
  // do something
}

Animation Finished

switch.animationDidStop = {  
  // do something
}

About

I made this switch to practice my skills in animation.

The implementation inspired by Marin Todorov book iOS Animations by Tutorials and Ramotion Inc. animation on Dribble. Please note that this Ramotion Inc. provided their own implementation, but it uses another approach for animation.

主要指标

概览
名称与所有者alsedi/AnimatedSwitch
主编程语言Swift
编程语言Swift (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2016-04-19 10:44:08
推送于2018-10-26 15:46:17
最后一次提交2018-01-24 14:48:54
发布数0
用户参与
星数246
关注者数5
派生数23
提交数27
已启用问题?
问题数4
打开的问题数1
拉请求数3
打开的拉请求数1
关闭的拉请求数0
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?