Skip to content

SwitchButton is a custom Button where you can on/off event button, like Check/Uncheck button, Radio Button On/Off, Switch On/Off. All you need is just images of On/Off.

Notifications You must be signed in to change notification settings

Jignesh-Gangajaliya/SwitchButton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

On/Off Custom Control

Awesome Platform Xcode

Demo

Introduction

This class aims to make it super-easy to on/off event button, example, Check/Uncheck button, Radio Button On/Off, Switch On/Off. All you need is just images of On/Off.

You can also get the button click event using confirming the SwitchButtonDelegate Protocol

Usage

Create a IBOutlet in ViewController

@IBOutlet weak var btnCheckMark: SwitchButton!

How to set On/Off value:

btnCheckMark.setStatus(true) // Set the on/off bool value

Get the status of button:

print(btnCheckMark.status) // 

Get the Click Event When tap on button, For click event method you have to confirm the protocol.

btnCheckMark.delegate = self

extension YourClassName: SwitchButtonDelegate {
    func valueChangeEvent(isOn: Bool) {
        print(isOn)
    }
}
📑 Complete Example of `SwitchButton`
class MyViewController: UIViewController: SwitchButtonDelegate {
  @IBOutlet weak var btnCheckMark: SwitchButton!
  
  override func viewDidLoad() {
    super.viewDidLoad()
    print(btnCheckMark.status) // Get the current status of switch button
    btnCheckMark.setStatus(true) // Set the on/off bool value
    btnCheckMark.delegate = self // Confirm the delegate to get the click event of button
  }
  
  func valueChangeEvent(isOn: Bool) {
      print(isOn)
  }
}

About

SwitchButton is a custom Button where you can on/off event button, like Check/Uncheck button, Radio Button On/Off, Switch On/Off. All you need is just images of On/Off.

Topics

Resources

Stars

Watchers

Forks

Languages