Latest 0.1.1
Homepage https://github.com/dkalaitzidis/CustomUISwitch
License MIT
Platforms ios 10.0
Authors

CustomUISwitch

A custom UIControl class to use as UISwitch from Storyboards or Code.

Why CustomUISwitch

Hi! Recently i got some mockups for a new iOS from our ninja at Orfium (https://www.orfium.com) whose identity shall be kept hidden.

One of the screens contained a custom UISwitch, this was one of the first things that i started to work on ;)

What you get

Custom UISwitch

How to Install

There is two ways to install this library

Manual

  • Simply drag ‘n drop the CustomSwitch.swift file to your project
  • Download the Assets folder and add them to your project

CocoaPods

Add to your podfile

pod 'CustomSwitch', '~> 0.1'

How to use

Storyboard

  • Add a UIView to a UIViewController and change the class to CustomSwitch, done! Some properties are exposed for the user to change them.

Code

  • Create a CustomSwitch via code:
    let myCustomSwitch = CustomSwitch(frame: CGRect(x: 50, y: 50, width: 48, height: 14))
    self.view.addSubview(myCustomSwitch)
  • Get Switch value (on/off):
    myCustomSwitch.isOn { (value) in
    print(value)
    }

Available Properties

  • animationDuration: Double
  • isOn: Bool
  • isOnImage: String
  • isOffImage: String
  • onTintColor: UIColor
  • offTintColor: UIColor
  • padding: CGFloat
  • thumbOnTintColor: UIColor
  • thumbOffTintColor: UIColor
  • thumbTintColor: UIColor

Latest podspec

{
    "name": "CustomSwitch",
    "version": "0.1.1",
    "summary": "A custom UISwitch.",
    "swift_version": "4.0",
    "description": "A custom UIControl class to use as UISwitch from Storyboards or Code.",
    "homepage": "https://github.com/dkalaitzidis/CustomUISwitch",
    "screenshots": "https://camo.githubusercontent.com/144ff7d334c2918c87efca0bc13243860b1427bc/68747470733a2f2f696d6775722e636f6d2f4454667978595a2e706e67",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Dimitrios Kalaitzidis": "[email protected]"
    },
    "source": {
        "git": "https://github.com/dkalaitzidis/CustomUISwitch.git",
        "tag": "0.1.1"
    },
    "social_media_url": "https://twitter.com/kalaitzidis34",
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "CustomSwitch/Classes/**/*",
    "resource_bundles": {
        "CustomSwitch": [
            "CustomSwitch/Assets/imageAssets/*.png"
        ]
    }
}

Pin It on Pinterest

Share This