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
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
A Material Design drop down for iOS

A Material Design drop down for iOS written in Swift. Demo Do pod try DropDown in your console and run the project to try a demo. To install CocoaPods

AssistoLab 2.3k Dec 20, 2022
Modular and customizable Material Design UI components for iOS

Material Components for iOS Material Components for iOS (MDC-iOS) helps developers execute Material Design. Developed by a core team of engineers and

Material Components 4.6k Dec 29, 2022
Blobmorphism is a brand new design language I've created to break free of the material overload in iOS, built in SwiftUI. Everything feels smooth and fluid.

Blobmorphism is a brand new design language I've created to break free of the material overload in iOS, built in SwiftUI. Everything feels smooth and fluid.

Ethan Lipnik 89 Nov 29, 2022
The Napp Drawer module extends the Appcelerator Titanium Mobile framework.

Titanium Napp Drawer Module Description The Napp Drawer module extends the Appcelerator Titanium Mobile framework. The module is licensed under the MI

null 12 Sep 15, 2022
Material, a UI/UX framework for creating beautiful iOS applications

Material Welcome to Material, a UI/UX framework for creating beautiful applications. Material's animation system has been completely reworked to take

Cosmicmind 12k Jan 2, 2023
Convenient domain specific language for writing programmatic UI built over UIKit and more.

XYKit Swifty and convenient domain specific language for creating programmatic UI in a more declarative way and more than that. Built on top of UIKit

Denis Goloborodko 1 Nov 5, 2021
A nice iOS View Capture Swift Library which can capture all content.

SwViewCapture A nice iOS View Capture Library which can capture all content. SwViewCapture could convert all content of UIWebView to a UIImage. 一个用起来还

Xing Chen 597 Nov 22, 2022
A library, which adds the ability to hide navigation bar when view controller is pushed via hidesNavigationBarWhenPushed flag

HidesNavigationBarWhenPushed A library, which adds the ability to hide navigation bar when view controller is pushed via hidesNavigationBarWhenPushed

Danil Gontovnik 55 Oct 19, 2022
Protocol oriented, type safe, scalable design system foundation swift framework for iOS.

Doric: Design System Foundation Design System foundation written in Swift. Protocol oriented, type safe, scalable framework for iOS. Features Requirem

Jay 93 Dec 6, 2022
Electronic Design in Swithft

Edith Electronic design in Swithft Serendipitously, the first woman to be professionally employed as an electrical engineer in the United States was a

CIRCT 37 Nov 3, 2021
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.

BadgeHub A way to quickly add a notification badge icon to any view. Demo/Example For demo: $ pod try BadgeHub To run the example project, clone the r

Jogendra 772 Dec 28, 2022
Confetti View lets you create a magnificent confetti view in your app

ConfettiView Confetti View lets you create a magnificent confetti view in your app. This was inspired by House Party app's login screen. Written in Sw

Or Ron 234 Nov 22, 2022
☠️ An elegant way to show users that something is happening and also prepare them to which contents they are awaiting

Features • Guides • Installation • Usage • Miscellaneous • Contributing ?? README is available in other languages: ???? . ???? . ???? . ???? . ???? To

Juanpe Catalán 11.7k Jan 6, 2023
A framework which helps you attach observers to `UIView`s to get updates on its frame changes

FrameObserver is a framework that lets you attach observers to any UIView subclass and get notified when its size changes. It doesn't use any Method S

null 11 Jul 25, 2022
A little app which shows different ways to simulate NSPanel using NSWindow

FunWithPanels A little app which shows different ways to simulate NSPanel using NSWindow, for better or worse. Settings FunWithPanels uses a combinati

Mitchell Cohen 7 Aug 3, 2022
IHTypeWriterLabel - A simple, UILabel subclass which poulates itself as if being typed

IHTypeWriterLabel A simple, UILabel subclass which poulates itself as if being typed. HighLights Written purely in SWIFT. Very simple and lightweight.

Md Ibrahim Hassan 24 May 7, 2019
A custom UIControl which functions like UISlider where you can set multiple intervals with different step values for each interval.

MultiStepSlider A custom UIControl which functions like UISlider where you can set multiple intervals with different step values for each interval. Th

Susmita Horrow 25 Apr 28, 2022
Cool Animated music indicator view written in Swift

Cool Animated music indicator view written in Swift. ESTMusicIndicator is an implementation of NAKPlaybackIndicatorView in Swift for iOS 8. 本人著作的书籍《La

Aufree 465 Nov 28, 2022