💊 An iOS switch control implemented in Swift with full Interface Builder support

Overview
'   :::===  :::  ===  === ::: :::==== :::===== :::  ===
'   :::     :::  ===  === ::: :::==== :::      :::  ===
'    =====  ===  ===  === ===   ===   ===      ========
'       ===  ===========  ===   ===   ===      ===  ===
'   ======    ==== ====   ===   ===    ======= ===  ===
'                                                              

Switch

CI Status GitHub issues Codecov Documentation

GitHub release Platform License

Carthage

CocoaPods CocoaPods downloads

Description

An iOS switch control implemented in Swift with full Interface Builder support.

To run the demo project:

pod try RoundedSwitch

Switch

Switch

Usage

Either config the switch in the Interface Builder or programatically as follow:

import Switch
...
let mySwitch = Switch()
mySwitch.leftText = "Windows"
mySwitch.rightText = "Mac"
mySwitch.rightSelected = true
mySwitch.tintColor = UIColor.purple
mySwitch.disabledColor = mySwitch.tintColor.withAlphaComponent(0.4)
mySwitch.backColor = mySwitch.tintColor.withAlphaComponent(0.05)
mySwitch.sizeToFit()
mySwitch.addTarget(self, action: #selector(ViewController.switchDidChangeValue(_:)), for: .valueChanged)

Please note that the module name is Switch. However, when installed with CocoaPods, it is RoundedSwitch.

Please see the Reference Documentation for details.

Installation

Carthage

Add the line below to your Cartfile:

github "T-Pham/Switch"

CocoaPods

Add the line below to your Podfile:

pod 'RoundedSwitch'

Manually

Add the file Switch.swift to your project. You are all set.

Compatibility

From version 2.0.0, Swift 3 syntax is used. If your project is still using Swift version 2, please use a UITextField-Navigation version prior to 2.0.0.

Podfile

pod 'RoundedSwitch', '~> 1.0.3'

or Cartfile

github "T-Pham/Switch" ~> 1.0.3

License

Switch is available under the MIT license. See the LICENSE file for more info.

You might also like...
An eject button for Interface Builder to generate swift code

Eject Eject is a utility to transition from Interface Builder to programatic view layout. This is done by using code generation to create a .swift fil

Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.
Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.

Design and prototype customized UI, interaction, navigation, transition and animation for App Store ready Apps in Interface Builder with IBAnimatable.

Localize your views directly in Interface Builder with IBLocalizable
Localize your views directly in Interface Builder with IBLocalizable

Localize your views easily in Interface Builder with IBLocalizable. With IBLocalizable, you can localize your views in Interface Builder easily. Simpl

A linter tool for Interface Builder
A linter tool for Interface Builder

IBLinter A linter tool to normalize .xib and .storyboard files. Inspired by realm/SwiftLint Installation Using Homebrew $ brew install iblinter Using

Design shapes in Interface Builder
Design shapes in Interface Builder

EPShapes Create shapes(Polygons, Stars, Hearts, Arrows) in Interface builder using IBInspectable and IBDesignable Features Design shapes in interface

Live rendering of UIImageView properties in Interface Builder
Live rendering of UIImageView properties in Interface Builder

TJProfileImage Live rendering of componet’s properties in Interface Builder Features Dashed border Solid border Round corner Circle image Requirements

A Custom UIButton with Centralised Styling and common styles available in Interface Builder
A Custom UIButton with Centralised Styling and common styles available in Interface Builder

DesignableButton DesignableButton is a UIButton subclass that uses a centralised and reusable styling. In InterfaceBuilder, drag and drop a Designable

Custom Field component with validation for creating easier form-like UI from interface builder.
Custom Field component with validation for creating easier form-like UI from interface builder.

#YALField Custom Field component with validation for creating easier form-like UI from interface builder. ##Example Project To run the example project

Introducing with Xcode Storyboard and Interface Builder

I-am-rich Introducing with Xcode Storyboard and Interface Builder Introducing wi

Setup your class structure in Xcode Interface Builder and save() in Parse Server.
Setup your class structure in Xcode Interface Builder and save() in Parse Server.

ISParseBind With ISParseBind you can save, update and query PFObjects using the power of Xcode Interface Builder resources. https://www.youtube.com/wa

Runkeeper design switch control
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

Swift-when - Expression switch support in Swift

Swift When - supporting switch expressions in Swift! What is it? Basically, it a

Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]

Extremely Fast views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainabl

An infinite scroll control implemented with two views.

LCCycleBanner An infinite scroll control implemented with two views. Requirements iOS 9.0+ Swift 4.0+ Programming in Objective-C? Try LCInfiniteScroll

Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast
Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast

Fast Swift Views layouting without auto layout. No magic, pure code, full control and blazing fast. Concise syntax, intuitive, readable & chainable. [iOS/macOS/tvOS/CALayer]

BCSwiftTor - Opinionated pure Swift controller for Tor, including full support for Swift 5.5 and Swift Concurrency

BCSwiftTor Opinionated pure Swift controller for Tor, including full support for

Open source, native iOS Messenger, with realtime chat conversations (full offline support).
Open source, native iOS Messenger, with realtime chat conversations (full offline support).

OVERVIEW This is a native iOS Messenger app, with realtime chat conversations (full offline support). NEW FEATURES Passcode support GraphQL server sup

Open source, native iOS Messenger, with realtime chat conversations (full offline support).
Open source, native iOS Messenger, with realtime chat conversations (full offline support).

OVERVIEW This is a native iOS Messenger app, with realtime chat conversations (full offline support). NEW FEATURES Passcode support GraphQL server sup

Control Room : a macOS app that lets you control the simulators for iOS, tvOS, and watchOS
Control Room : a macOS app that lets you control the simulators for iOS, tvOS, and watchOS

Control Room is a macOS app that lets you control the simulators for iOS, tvOS, and watchOS – their UI appearance, status bar configuration, and more.

Comments
  • Property for the switch background color

    Property for the switch background color

    Hi, I've downloaded your lib because I've found it really nice. But when I've started to use it, I've found something missing.

    What I've found:

    I have found that it is impossible to just change the switch background color. When you use the "backgroundColor" property nothing happen and the background still stay in white.

    What I've done :

    • I have created an IBDesignable property called "backColor" to allows user to change the switch background color.
    • I also have created a new test function to be sure the code I've written works.

    Commit description :

    Added property to change the switch background color. Added test for the property.

    opened by Darkkrye 5
  • Change font

    Change font

    Hey

    Really nice pod. However, I can't seem to easily change the font of the buttons. Could you perhaps create that feature? I'm a little busy so I don't have time to PR it at the moment.

    Thanks

    opened by nickdnk 2
  • Some devices have problem with tap

    Some devices have problem with tap

    Hi,

    I've tested the library on a lot of simulator devices and also on real devices (iphone 5,6,6s and 7) Everything was playing perfect except iphone 7 (the simulator with the same ios version was playing good). When I try to tap the second item to be selected nothing happens then I tried to tap it very quick and a lot of times it worked (No clue why) but again to tap the other one I had to tap it a lot of times and very quick.

    I deleted my app, restarted my phone, deleted derived data and install it again but the problem insist

    Edit

    I use xcode 9 and my iphone 7 that has this problem runs with ios 11.

    opened by mvorisis 1
Owner
Thanh Pham
👨‍💻 iOS & Roku
Thanh Pham
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
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
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
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
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
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
🔥 🔥 🔥Support for ORM operation,Customize the PQL syntax for quick queries,Support dynamic query,Secure thread protection mechanism,Support native operation,Support for XML configuration operations,Support compression, backup, porting MySQL, SQL Server operation,Support transaction operations.

?? ?? ??Support for ORM operation,Customize the PQL syntax for quick queries,Support dynamic query,Secure thread protection mechanism,Support native operation,Support for XML configuration operations,Support compression, backup, porting MySQL, SQL Server operation,Support transaction operations.

null 60 Dec 12, 2022
RCalendarPicker A date picker control, Calendar calendar control, select control, calendar, date selection, the clock selection control.

RCalendarPicker RCalendarPicker Calendar calendar control, select control, calendar, date selection, the clock selection control. 日历控件 ,日历选择控件,日历,日期选择

杜耀辉 131 Jul 18, 2022
Full Bitcoin library for iOS, implemented on Swift. SPV wallet implementation for Bitcoin, Bitcoin Cash and Dash blockchains.

BitcoinKit-iOS Bitcoin, BitcoinCash(ABC) and Dash wallet toolkit for Swift. This is a full implementation of SPV node including wallet creation/restor

Horizontal Systems 231 Dec 2, 2022