All Projects → d-dotsenko → Ddanimatedswitch

d-dotsenko / Ddanimatedswitch

Licence: mit
👍🏼 Awesome animated switch

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Ddanimatedswitch

Viewtooltip
A fluent tooltip for Android
Stars: ✭ 1,029 (+729.84%)
Mutual labels:  sample, custom
Aiflatswitch
Nicely animated flat design switch alternative to UISwitch
Stars: ✭ 904 (+629.03%)
Mutual labels:  switch, custom
Yi Hack Allwinner V2
Custom firmware for Yi 1080p camera based on Allwinner platform
Stars: ✭ 100 (-19.35%)
Mutual labels:  custom
Oblate
Custom theme for my personal website and blog.
Stars: ✭ 117 (-5.65%)
Mutual labels:  custom
Playground
Playground
Stars: ✭ 108 (-12.9%)
Mutual labels:  sample
Ios11 Pdfkit Example
Sample code for PDFKit on iOS 11.
Stars: ✭ 105 (-15.32%)
Mutual labels:  sample
Netcopa
Network Configuration Parser
Stars: ✭ 112 (-9.68%)
Mutual labels:  switch
Mini Graph Card
Minimalistic graph card for Home Assistant Lovelace UI
Stars: ✭ 1,370 (+1004.84%)
Mutual labels:  custom
Mq Docker
[DEPRECATED] Sample Docker image for IBM® MQ
Stars: ✭ 120 (-3.23%)
Mutual labels:  sample
Jhform
JhForm - 自定义表单工具,更加简单,快捷的创建表单、设置页面
Stars: ✭ 108 (-12.9%)
Mutual labels:  switch
Swifitch
Swifitch is ESP8266 based relay board that could be used to turn any light or any wall socket into smart one!
Stars: ✭ 117 (-5.65%)
Mutual labels:  switch
Ar Position
ActiveRecord behavior, which provides ability for custom records order setup
Stars: ✭ 107 (-13.71%)
Mutual labels:  custom
Android Kotlin Clean Architecture
Android Sample Clean Architecture App written in Kotlin
Stars: ✭ 1,562 (+1159.68%)
Mutual labels:  sample
Golang Gin Realworld Example App
Exemplary real world application built with Golang + Gin
Stars: ✭ 1,780 (+1335.48%)
Mutual labels:  sample
Cloud Espm V2
This sample is a reference application project, showcasing an end-to-end development scenario for a Java-based app on SAP Cloud Platform. The app has a SAPUI5 web frontend, uses OData to connect to a Java-based cloud backend which in turn connects via JPA to an SAP HANA DB in the cloud.
Stars: ✭ 104 (-16.13%)
Mutual labels:  sample
Sscustomedittextoutlineborder
Same as an Outlined text fields presented in Material Design page but with some dynamic changes
Stars: ✭ 119 (-4.03%)
Mutual labels:  custom
Mkloader
Beautiful and smooth custom loading views
Stars: ✭ 1,377 (+1010.48%)
Mutual labels:  custom
Not Your Average Web Crawler
A web crawler (for bug hunting) that gathers more than you can imagine.
Stars: ✭ 107 (-13.71%)
Mutual labels:  custom
Homebridge Http Switch
Powerful http switch for Homebridge: https://github.com/homebridge/homebridge
Stars: ✭ 111 (-10.48%)
Mutual labels:  switch
Bettersegmentedcontrol
An easy to use, customizable replacement for UISegmentedControl & UISwitch.
Stars: ✭ 1,782 (+1337.1%)
Mutual labels:  switch

Customizable Animated Switch

Platform License Version Carthage compatible Swift 4.2

This framework allows you to create and customize all types of switches. You can setup very complex and very simple switches using just a few lines of code.

DDAnimatedSwitch

An animated switch can use any frame animation. You can animate not only the switch but also the thumb. Animations can be played, resized, looped, sped up, slowed down and reversed. You can set any forms, sizes and proportions.

DDAnimatedSwitch

The framework has a large number of settings for animation. Changing them you will create a unique and beautiful switch. Here is an another sample.

DDAnimatedSwitch

In addition to animation, you can create customizable switch with labels or images. All these elements can also be animated and decorated.

DDAnimatedSwitch

Be careful!!!

Irreversible consequences are possible during long work with the framework. DDAnimatedSwitch

Installation

DDAnimatedSwitch supports CocoaPods and Carthage.

CocoaPods

To install DDAnimatedSwitch via CocoaPods, add the following line to your Podfile:

pod 'DDAnimatedSwitch'

After installing the cocoapod into your project import DDAnimatedSwitch with:

import DDAnimatedSwitch

Carthage

To install DDAnimatedSwitch via Carthage, add the following line to your Cartfile:

github "d-dotsenko/DDAnimatedSwitch"

And then run:

carthage update

Manually

Add DDAnimatedSwitch folder to your Xcode project.

Usage

The framework contains several basic classes. Each class allows you to create and configure a specific type of switch. All this classes inherited from DDSwitch If you need a custom switch with animated labels - create switch inheriting from DDLabelSwitch

DDAnimatedSwitch

If you need a custom switch with animated images - create switch inheriting from DDImageSwitch

DDAnimatedSwitch

if you need a custom switch with frame animation of the switch and / or thumb - create switch inheriting from DDAnimatedSwitch

DDAnimatedSwitch

if you need just a unique and beautiful switch - create class inheriting from DDSwitch

DDAnimatedSwitch

See the example Xcode project.

Quick Start

  1. Create a new switch inheriting from DDAnimatedSwitch

  2. Configuration.

Consider an example for DDLabelSwitch

onTintColor = UIColor.orange
offTintColor = UIColor.lightGray

cornerRadius = 0.5
thumbCornerRadius = 0.5
thumbTintColor = UIColor(red: 0.9, green: 0.9, blue: 0.9, alpha: 1)
padding = frame.size.height / 50
let side = frame.size.height - 2 * padding
thumbSize = CGSize(width: side/2, height: side)
duration = 0.8

thumbShadowColor = UIColor.black
thumbShadowOffset = CGSize(width: 0, height: 0)
thumbShadowRadius = 3
thumbShadowOpacity = 0.7

innerShadowColor = UIColor.black
innerShadowRadius = 7
innerShadowOpacity = 0.5

let labelOn = UILabel()
labelOn...

let labelOff = UILabel()
labelOff...

onLabel = labelOn
offLabel = labelOff

Consider an example for DDAnimatedSwitch

cornerRadius = 0.5
thumbTintColor = UIColor.clear
padding = frame.size.height / 4
let side = frame.size.height / 1.5
thumbSize = CGSize(width: side, height: side)
duration = 0.8

thumbShadowColor = UIColor.white
thumbShadowOffset = CGSize(width: 0, height: 0)
thumbShadowRadius = 10
thumbShadowOpacity = 1

thumbAnimationName = "MoonSunAnimation"         /// --> frame animation name
backgroundAnimationName = "ForestAnimation"     /// --> frame animation name
  1. If you want switch with frame animation you have to create it. Add images to assert (main bundle) for switch and / or thumb.
DDAnimatedSwitch

After that, create .plist with names for each animation.

DDAnimatedSwitch

Set for thumbAnimationName and / or backgroundAnimationName name of plist.

Customization

// DDSwitch
var isOn: Bool // The switch value
var animated: Bool // A Boolean value that determines whether switch changes are animated
var duration: CGFloat // The animation duration value
var padding: CGFloat // Minimum left/right thumb offset
var onTintColor: UIColor // The switch background color if thumb is On
var offTintColor: UIColor // The switch background color if thumb is Off
var thumbTintColor: UIColor // The thumb background color
var cornerRadius: CGFloat // The switch corner radius (0.0 ... 0.5)
var thumbCornerRadius: CGFloat // The thumb corner radius (0.0 ... 0.5)
var thumbSize: CGSize // The thumb size
var thumbImage: UIImage? // The thumb image
var isThumbImageColorAnimate: Bool // A Boolean value that determines whether thumb imageView tint color is
inversed of the switch background color during animation switch changes are animated
var thumbShadowColor: UIColor // The thumb shadow color
var thumbShadowOffset: CGSize // The thumb shadow offset
var thumbShadowRadius: CGFloat // The thumb shadow radius
var thumbShadowOpacity: Float // The thumb shadow opacity
var innerShadowColor: UIColor // Inner shadow collor of the switch
var innerShadowRadius: CGFloat // Inner shadow radius of the switch
var innerShadowOpacity: Float // Inner shadow opacity of the switch

// DDAnimatedSwitch
var thumbAnimationName: String? // The name of plist with names of frame images for thumb animation
var backgroundAnimationName: String? // The name of plist with names of frame images for switch animation 

// DDLabelSwitch
var onLabel: UILabel? // The label if thumb is On
var offLabel: UILabel? // The label if thumb is Off

// DDImageSwitch
var onImageView: UIImageView? // The image if thumb is On
var offImageView: UIImageView? // The image if thumb is Off

Requirements

  • iOS 9.0
  • Xcode 10, Swift 4.2

License

DDAnimatedSwitch is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].