Toggler 1.0.0

Toggler 1.0.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Oct 2017
SwiftSwift Version 4.0
SPMSupports SPM

Maintained by [younatics].



Toggler 1.0.0

  • By
  • Seungyoun Yi

Intoduction

💡 don't further use isSelected to every button. use Toggler to simply control your buttons demo demo

Don't do like these any more

    func buttonClicked(_ sender: UIButton) {
        switch sender.tag {
        case 0:
            button1.isSelected = true
            button2.isSelected = false
            button3.isSelected = false
            button4.isSelected = false
            button5.isSelected = false
        case 1:
            button1.isSelected = false
            button2.isSelected = true
            button3.isSelected = false
            button4.isSelected = false
            button5.isSelected = false
        case 2:
            button1.isSelected = false
            button2.isSelected = false
            button3.isSelected = true
            button4.isSelected = false
            button5.isSelected = false
        case 3:
            button1.isSelected = false
            button2.isSelected = false
            button3.isSelected = false
            button4.isSelected = true
            button5.isSelected = false
        case 4:
            button1.isSelected = false
            button2.isSelected = false
            button3.isSelected = false
            button4.isSelected = false
            button5.isSelected = true
        default:
            break
        }
    }

Use Toggler

func buttonClicked(_ sender: UIButton) {
    toggler.on(toggle: sender)
}

Requirements

Toggler is written in Swift 3. Compatible with iOS 8.0+

Usage

Init with UIButton or UISwtich and default index

toggler = Toggler(default: 0, togglers: [button1, button2, button3, button4, button5])

Toggle button

toggler.on(toggle: sender)
toggler.onAt(index: sender.tag)

Add more button

toggler.add(toggle: button6)

Remove button

toggler.remove(at: 5)

References

Please tell me or make pull request if you use this library in your application :)

Author

younatics 🇰🇷

License

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