Giter Club home page Giter Club logo

animatedswitch's Introduction

#AnimatedSwitch Swift 2.2 InerfaceBuilder Designable Twitter

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 2.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

Callbacks

Animation started

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

Animation Finished

switch.animationDidStop = { _ in 
  // 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.

animatedswitch's People

Contributors

alsedi avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.