Code Monkey home page Code Monkey logo

paper-switch's Introduction

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.



paper-switch's People

Contributors

0ber avatar aleksei1000000 avatar alexmik89 avatar devladinci avatar eddpt avatar hammadzz avatar igork-ramotion avatar ikolpachkov avatar juriv avatar kaphacius avatar ooleynich avatar ramotiondev avatar ramotionrussell avatar ronnielsen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paper-switch's Issues

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

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πŸ’

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

Change repo name

screen shot 2016-06-24 at 10 22 52 pm

Repo name is **paper-switch** but the whole `Readme.md` mentions **RAMPaperSwitch**

Objective-c Compatibility

Is it compatible Objective-c ? The override change stat doesn't call with Objective-c code.
Thanks in advance.

Cocoapods Class Is Not Public

in RAMPaperSwitch.swift, the RAMPaperSwitch is not defined as public so there is no way to create an RAMPaperSwitch programmatically.

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?

Typo

There is a tiny typo in "switchChangeWithAnimation(_ animation:)" method name! Β―_(ツ)_/Β―

typo

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?

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.