GithubHelp home page GithubHelp logo

junichit / jtmaterialswitch Goto Github PK

View Code? Open in Web Editor NEW
319.0 10.0 46.0 8.47 MB

A Customizable Switch UI for iOS, Inspired from Google's Material Design

License: MIT License

Objective-C 98.70% Ruby 1.30%

jtmaterialswitch's Introduction

JTMaterialSwitch

CI Status Version License Platform

Overview

JTMaterialSwitch is google's material design like switch UI with animation features.

This library has cool and sophisticated animations, ripple effect and bounce effect. Also, customizable properties can be tweaked behaviors and enhance your application UI cool.

With this library, you can easily implement material design switch to your app.



Installation

JTMaterialSwitch is available on CocoaPods.

You can use this library by adding the following command onto your Podfile:

pod "JTMaterialSwitch"

Usage

The simplest setup:

  JTMaterialSwitch *switch = [[JTMaterialSwitch alloc] init];
  switch.center = CGPointMake(200, 200);
  [self.view addSubview:switch];

This is the simplest and easiest initialization. The style, size and initial state of JTMaterialSwitch instance is set to all default value as shown below.

In addition, this library also has following designated initializers to set these parameters.

 /**
  *  Initializes a JTMaterialSwitch with a initial switch state position and size.
  *
  *  @param size A JTMaterialSwitchSize enum as this view's size(big, normal, small)
  *  @param state A JTMaterialSwitchState enum as this view's initial switch pos(ON/OFF)
  *
  *  @return A JTMaterialSwitch with size and initial position
  */
 - (id)initWithSize:(JTMaterialSwitchSize)size state:(JTMaterialSwitchState)state;

 /**
  *  Initializes a JTMaterialSwitch with a initial switch size, style and state.
  *
  *  @param size A JTMaterialSwitchSize enum as this view's size(big, normal, small)
  *  @param state A JTMaterialSwitchStyle enum as this view's initial style
  *  @param state A JTMaterialSwitchState enum as this view's initial switch pos(ON/OFF)
  *
  *  @return A JTMaterialSwitch with size, style and initial position
  */
- (id)initWithSize:(JTMaterialSwitchSize)size style:(JTMaterialSwitchStyle)style state:(JTMaterialSwitchState)state;

Customize Behaviors

JTMaterialSwitch has many prateters to customize behaviors as you like.

Style and size

  • Style: JTMaterialSwitchStyle

  • JTMaterialSwitchStyleLight

  • JTMaterialSwitchStyleDark

  • JTMaterialSwitchStyleDefault

  • Size: JTMaterialSwitchSize

  • JTMaterialSwitchSizeBig

  • JTMaterialSwitchSizeNormal

  • JTMaterialSwitchSizeSmall

Screen shot

Properties

#pragma State
/** A Boolean value that represents switch's current state(ON/OFF). YES to ON, NO to OFF the switch */
@property (nonatomic) BOOL isOn;
/** A Boolean value that represents switch's interaction mode. YES to set enabled, No to set disabled*/
@property (nonatomic) BOOL isEnabled;
/** A Boolean value whether the bounce animation effect is enabled when state change movement */
@property (nonatomic) BOOL isBounceEnabled;
/** A Boolean value whether the ripple animation effect is enabled or not */
@property (nonatomic) BOOL isRippleEnabled;

#pragma Color
/** An UIColor property to represent the color of the switch thumb when position is ON */
@property (nonatomic, strong) UIColor *thumbOnTintColor;
/** An UIColor property to represent the color of the switch thumb when position is OFF */
@property (nonatomic, strong) UIColor *thumbOffTintColor;
/** An UIColor property to represent the color of the track when position is ON */
@property (nonatomic, strong) UIColor *trackOnTintColor;
/** An UIColor property to represent the color of the track when position is OFF */
@property (nonatomic, strong) UIColor *trackOffTintColor;
/** An UIColor property to represent the color of the switch thumb when position is DISABLED */
@property (nonatomic, strong) UIColor *thumbDisabledTintColor;
/** An UIColor property to represent the color of the track when position is DISABLED */
@property (nonatomic, strong) UIColor *trackDisabledTintColor;
/** An UIColor property to represent the fill color of the ripple only when ripple effect is enabled */
@property (nonatomic, strong) UIColor *rippleFillColor;

Screen shot

Change History

1.1 Bug Fix

1.0.0 Initial Release

Requirements

iOS 7.0 or later

Author

Junichi Tsurukawa [email protected]

License

JTMaterialSwitch is available under the MIT license.

jtmaterialswitch's People

Contributors

junichit 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

jtmaterialswitch's Issues

How to find which switch delegate called?

Hi,

I am using multiple switch in same view. So I don't know which switch delegate called when switch state change. If any way to find that let me know if I miss anything.

Thanks,

Using JTMaterialSwitch in Swift 4

declare JTMaterialSwitch
let Switch = JTMaterialSwitch()

se switch color
Switch?.thumbOnTintColor = UIColor.init(hex: 0xF9D059)

add switch to UIView
View.addSubview(Switch!)

Swift 4 using

You can use JTMaterialSwith in Swift 4 as

let PushNotificationsSwitch = JTMaterialSwitch()

isBounceEnabled property has no effect

It appears that the isBouncEnabled property has no affect on the control.

  1. Initialize a new JTMaterialSwitch [[JTMaterialSwitch alloc] init];
  2. Set the isBounceEnabled property to NO
  3. Add switch to the view
  4. Observe that the switch still "bounces" when transitioning between on and off states

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.