A Swift material design UI module which paints over the parent view when the switch is on.

Overview

PAPER SWITCH

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 custom UI for Mobile Apps and Websites.

Stay tuned for the latest updates:


CocoaPods CocoaPods CocoaPods Carthage compatible Twitter Travis Donate

Requirements

  • iOS 8.0+
  • Xcode 9.0+

Installation

Just add the RAMPaperSwitch folder to your project.

or use CocoaPods with Podfile:

pod 'RAMPaperSwitch' 

or Carthage users can simply add to their Cartfile:

github "Ramotion/paper-switch"

Usage

RAMPaperSwitch is a drop-in replacement of UISwitch. You just need to set the onTintColor property of the switch, and it will automatically paint over its superview with the selected color. You have ability to set duration of animation instead of default value.

  1. Create a new UISwitch in your storyboard or nib.

  2. Set the class of the UISwitch to RAMPaperSwitch in your Storyboard or nib.

  3. Set onTintColor for the switch

  4. Set duration property programmatically if You want to change animation duration.

  5. Add animation for other views near the switch if need.

Animate views

You can animate other views near the switch. For example, you can change color to views or labels that are inside the same superview. Duration of animation can be gotten from the RAMPaperSwitch's property duration. You can animate CoreAnimation properties like this:

self.paperSwitch.animationDidStartClosure = {(onAnimation: Bool) in
    UIView.transitionWithView(self.label, duration: self.paperSwitch.duration, options: UIViewAnimationOptions.TransitionCrossDissolve, animations: {
        self.label.textColor = onAnimation ? UIColor.whiteColor() : UIColor.blueColor()
    }, completion:nil)
}

πŸ“„ License

Paper Switch is released under the MIT license. See LICENSE for details.

This library is a part of a selection of our best UI open-source projects.

If you use the open-source library in your project, please make sure to credit and backlink to www.ramotion.com

πŸ“± Get the Showroom App for iOS to give it a try

Try this UI component and more like this in our iOS app. Contact us if interested.



Comments
  • Issue when switch is set to true from init.

    Issue when switch is set to true from init.

    Hi!

    Love your work. I have an issue where if i set the .setOn property to true, then the switch doesn't work. When I toggle it, it won't change the color of the view.

    Do you have any way around this?

    opened by henryhardy 3
  • Toggled switch overlaps table view cells

    Toggled switch overlaps table view cells

    Thanks for putting paper-switch together! I immediately found uses for it and started putting it to work.

    Not sure if it's expected or not, but I noticed when placing the switch into a table view's cell, the color bounds goes past the bounds of views inside the cell or even the cell's bounds itself. Could it be that I'm doing something wrong here?

    Screenshot

    opened by gregbarbosa 3
  • EXC_BAD_INSTRUCTION (code=1, subcode=0x0)

    EXC_BAD_INSTRUCTION (code=1, subcode=0x0)

    Screen Shot 2020-04-09 at 12 38 09 PM I have followed all instructions on installation and used both code provided in the sample and on Github. In the above picture, both functions, when run on phones, have the same error on "animationDidStartClosure". I was not able to find any information regarding this specific error. Can you help me out?

    An additional picture is attached with more information. Screen Shot 2020-04-09 at 12 44 31 PM

    Thanks, Sam

    opened by 72WaystoKillaPotato 1
  • Swift 3

    Swift 3

    Scope

    • [x] Migrate to Swift 3
    • [x] Use Storyboard for the demo
    • [x] Update the demo
    • [x] Remove print on state
    • [x] Remove ;

    Notes

    • Extensions are removed since there are issues with private, fileprivate, accessing vars and etc
    • Note that release should be major (2.0) in order to have support both swift 2.2 ( Pod ver. 1.0.7 ) and swift 3 (2.0.0)
    opened by devladinci 1
  • Programmatically set ontintcolor

    Programmatically set ontintcolor

    Hello,

    I tried setting the ontintcolor programatically, this doesn't seem to work. only through storyboard.

    self.paperSwitch1.onTintColor = UIColor(red: 241/255, green: 196/255, blue: 15/255, alpha: 1)
    self.setupColorSwitch()
    

    I set this in the viewDidLoad function but it doesn't seem work, anyone now a solution?

    opened by thomascsorbamedia 1
  •  rebuild 'PaperOnboarding'

    rebuild 'PaperOnboarding'

    I upgraded to Xcode 9 and now I experienced bellow issue: "Module file was created by an older version of the compiler; rebuild 'PaperOnboarding' and try again:"

    Please help me on itπŸ’

    opened by farzad789 0
  • project is buiding in my xcode but unable to run on simulator

    project is buiding in my xcode but unable to run on simulator

    all your projects are really good but when im trying to run the project is getting succeded in building but unable to run on simulator please let me know how can i run on simulator and it is showing no errors

    opened by rajeshj711 0
  • RAMPaperSwitch - Objective C port

    RAMPaperSwitch - Objective C port

    Hi, First thank you people at Ramotion for sharing the code. I really preferred porting PaperSwitch to Objective C than using Swift in a complex Objective C project.

    Cheers, L

    opened by lucaji 0
Owner
Ramotion
UI Engineering, UI/UX Design and Front-End Development Agency
Ramotion
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
A Customizable Switch UI for iOS, Inspired from Google's Material Design

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

Junichi Tsurukawa 319 Nov 28, 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
πŸ’Š An iOS switch control implemented in Swift with full Interface Builder support

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

Thanh Pham 145 Dec 7, 2022
An animation switch collection

TKSwitcherCollection An animate switch collection Requirements iOS 8.0+ Xcode 9.0 Swift 4.0 Installation CocoaPods You can use CocoaPods to install TK

TBXark 903 Dec 21, 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.

: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
UISwitch which paints over the parent view with the color in Swift.

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

Alex Sergeev 248 Jul 26, 2022
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
A Customizable Switch UI for iOS, Inspired from Google's Material Design

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

Junichi Tsurukawa 319 Nov 28, 2022
LOL Champions app: a small Multi-Module demo application to demonstrate modern iOS application tech-stacks with a Multi-module and MVVM architecture

LOL Champions app: a small Multi-Module demo application to demonstrate modern iOS application tech-stacks with a Multi-module and MVVM architecture

Ahmed Nasser 5 Jun 9, 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
Runkeeper design switch control

DGRunkeeperSwitch Runkeeper design switch control (two part segment control) developed in Swift 2.0 Requirements Xcode 7-beta or higher iOS 8.0 or hig

Danil Gontovnik 1.9k Dec 2, 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
Material design components for iOS written in Swift

MaterialKit NOTE: This project is unmaintained. Material design components (inspired by Google Material Design) for iOS written in Swift Please feel f

Le Van Nghia 2.5k Jan 5, 2023
⭕️ CircleMenu is a simple, elegant UI menu with a circular layout and material design animations. Swift UI library made by @Ramotion

CIRCLE MENU Simple, elegant UI menu with a circular layout and material design animations We specialize in the designing and coding of custom UI for M

Ramotion 3.4k Dec 29, 2022
iOS library Paper Onboarding is a material design UI slider written on Swift.

iOS library Paper Onboarding is a material design UI slider written on Swift. We specialize in the designing and coding of custom UI

Ramotion 3.2k Jan 5, 2023
A Slide Menu, written in Swift, inspired by Slide Menu Material Design

Swift-Slide-Menu (Material Design Inspired) A Slide Menu, written in Swift 2, inspired by Navigation Drawer on Material Design (inspired by Google Mat

Boisney Philippe 90 Oct 17, 2020
A swift library based on the various options menu in material design in Android

KTOptionMenu Description KTOptionMenu is a swift library based on the various options menu in material design in Android that allows you to easily cre

null 1 Jul 21, 2022