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

Overview

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.

You might also like...
SharePlay-TextEditor - An iOS & iPadOS application, by which people can write/edit texts and change font-styles/background color over FaceTime call A rapid prototype of UISwitch built with Swift and PaintCode.
A rapid prototype of UISwitch built with Swift and PaintCode.

LTJelloSwitch A cute UISwitch prototype built in about 8 hours. One of my co-worker gave me this concept last year. It was written in Objective-C and

System Color Picker - The macOS color picker as an app with more features
System Color Picker - The macOS color picker as an app with more features

System Color Picker The macOS color picker as an app with more features Download Requires macOS 11 or later. Features Quickly copy, paste, and convert

The purpose of the color game is to find the right color without getting distracted. It is as difficult as it is fun.
The purpose of the color game is to find the right color without getting distracted. It is as difficult as it is fun.

Color Game The purpose of the color game is to find the right color without getting distracted. It is as difficult as it is fun. Getting Started Insta

The purpose of the color game is to find the right color without getting distracted. It is as difficult as it is fun.
The purpose of the color game is to find the right color without getting distracted. It is as difficult as it is fun.

Color Game The purpose of the color game is to find the right color without getting distracted. It is as difficult as it is fun. Getting Started Insta

Simple utility to change macOS Big Sur menu bar color by appending a solid color or gradient rectangle to a wallpaper image
Simple utility to change macOS Big Sur menu bar color by appending a solid color or gradient rectangle to a wallpaper image

Change menu bar color in macOS Big Sur Simple utility to change macOS Big Sur menu bar color by appending a solid color or gradient rectangle to a wal

ColorAssetsFinder can help you find particular color assets easily by hex color code.
ColorAssetsFinder can help you find particular color assets easily by hex color code.

ColorAssetsFinder ColorAssetsFinder can help you find particular color assets easily by hex color code. Features Find particular color assets in Asset

A basic iOS app that takes input from the user, displays it, allows changing both text color and background color.
A basic iOS app that takes input from the user, displays it, allows changing both text color and background color.

Hello-iOSApp App Description A basic iOS app that takes input from the user, displays it, allows changing both text color and background color. App Wa

ColorWheel Test - An attempt at creating a Color Wheel to be utilized for color picking in SwiftUI utlizing various tutuorials on youtube

This code focuses on creating a Color Wheel in which a user will be able to select a desired color to then be implemented in another project that will display that color in an LED connected to an arduino

Make system color defined in UIColor/NSColor available to SwiftUI Color.
Make system color defined in UIColor/NSColor available to SwiftUI Color.

SwiftUIColor Make system color defined in UIColor/NSColor available to SwiftUI Color. About In this library, colors are defined in an asset file. Crea

An easy to use, customizable replacement for UISegmentedControl & UISwitch.
An easy to use, customizable replacement for UISegmentedControl & UISwitch.

BetterSegmentedControl BetterSegmentedControl is an easy to use, customizable replacement for UISegmentedControl and UISwitch written in Swift. Featur

iOS7 style drop in replacement for UISwitch
iOS7 style drop in replacement for UISwitch

SevenSwitch iOS7 style drop in replacement for UISwitch Usage Cocoapods pod 'SevenSwitch', '~ 2.1' Swift support was added in version 2.0. If your p

Nicely animated flat design switch alternative to UISwitch
Nicely animated flat design switch alternative to UISwitch

AIFlatSwitch A smooth, nice looking and IBDesignable flat design switch for iOS. Can be used instead of UISwitch. Inspired by Creativedash's Dribbble

SSToastMessage is written purely in SwiftUI. It will add toast, alert, and floating message view over the top of any view. It is intended to be simple, lightweight, and easy to use. It will be a popup with a single line of code.
SSToastMessage is written purely in SwiftUI. It will add toast, alert, and floating message view over the top of any view. It is intended to be simple, lightweight, and easy to use. It will be a popup with a single line of code.

SSToastMessage SSToastMessage is written in SwiftUI. It will add toast, alert, and floating message view over the top of any view. It is intended to b

A Layer-2 framework built over Keychain API which helps in using Keychain in all your Apple devices with easiness and flexibility.
A Layer-2 framework built over Keychain API which helps in using Keychain in all your Apple devices with easiness and flexibility.

Keychain Manager Keychain Manager is a Layer-2 framework built over Keychain API which helps in using Keychain in all your Apple devices with easiness

SSLineChart provides you with the additional functionality of gradient color fill which cannot be found in any library specially Watchkit Libraries.
SSLineChart provides you with the additional functionality of gradient color fill which cannot be found in any library specially Watchkit Libraries.

SSLineChart SSLineChart draws a UIImage of a chart with given values and provide additional functionality of gradient color fill. Setup Instructions C

Change SwiftUI Navigation Bar Color for different View
Change SwiftUI Navigation Bar Color for different View

SwiftUINavigationBarColor Change SwiftUI NavigationBar background color per screen. Usage For NavigationBarColor to work, you have to set the Navigati

This app is a sample app that recognizes specific voice commands such as
This app is a sample app that recognizes specific voice commands such as "make it red", "make it blue", "make it green", and "make it black" and change the background color of the view in the frame.

VoiceOperationSample This app is a sample app that recognizes specific voice commands such as "make it red", "make it blue", "make it green", and "mak

Comments
Owner
Alex Sergeev
Alex Sergeev
A UISwitch that infects its superview with its tint color.

UISwitch subclass that 'infects' the parent view with the onTintColor when the switch is turned on. Inspired by this Dribble by Ramotion. Screenshot I

Andrea Mazzini 337 Sep 12, 2022
iOS7 style drop in replacement for UISwitch

SevenSwitch iOS7 style drop in replacement for UISwitch Usage Cocoapods pod 'SevenSwitch', '~> 2.1' Swift support was added in version 2.0. If your p

Ben Vogelzang 779 Sep 5, 2022
Nicely animated flat design switch alternative to UISwitch

AIFlatSwitch A smooth, nice looking and IBDesignable flat design switch for iOS. Can be used instead of UISwitch. Inspired by Creativedash's Dribbble

null 963 Jan 5, 2023
A Customizable Switch UI for iOS, Inspired from Google's Material Design in Swift

MJMaterialSwitch Overview MJMaterialSwitch is google's material design like switch UI with animation features. This library has cool and sophisticated

Jaleel Nazir 64 Jul 29, 2022
💊 An iOS switch control implemented in Swift with full Interface Builder support

' :::=== ::: === === ::: :::==== :::===== ::: === ' ::: ::: === === ::: :::==== ::: ::: === ' ===== === === === === ===

Thanh Pham 145 Dec 7, 2022
Swift - Custom UISwitcher with animation when change status

Switcher Custom UISwitcher with animation. Thank to @andmironov for great design http://uimovement.com/ui/654/yet-another-toggle-animation/ Usage Add

Khoi Nguyen 205 Dec 5, 2022
A Swift material design UI module which paints over the parent view when the switch is on.

A Swift material design UI module which paints over the parent view when the switch is on. We specialize in the designing and coding of c

Ramotion 2.9k Dec 29, 2022
A Swift material design UI module which paints over the parent view when the switch is on.

:octocat: ?? RAMPaperSwitch is a Swift material design UI module which paints over the parent view when the switch is turned on. iOS library by @Ramotion

Ramotion 2.9k Dec 29, 2022
A UISwitch that infects its superview with its tint color.

UISwitch subclass that 'infects' the parent view with the onTintColor when the switch is turned on. Inspired by this Dribble by Ramotion. Screenshot I

Andrea Mazzini 337 Sep 12, 2022
A child view controller framework that makes setting up your parent controllers as easy as pie.

Description Family is a child view controller framework that makes setting up your parent controllers as easy as pie. With a simple yet powerful publi

Christoffer Winterkvist 246 Dec 28, 2022