UISegmentedControl is great, but it’s not animated, and has limits to how much you can customize it. UISwitch is great too, it is animated, but it’s limited to a yes/no choice, and customization again can be quite tricky. Today we’ll look at a library from George Marmaridis called BetterSegmentedControl that aims to helps us here.

Let’s try it out in a navigation bar:

let c = (titles: ["Lights On", "Lights Off"])

c.frame = CGRect(x: .0, y: 40.0, width: 200.0, height: 30.0)
c.cornerRadius = 3.0
c.titleFont = UIFont(name: "Avenir", size: 13.0)
c.backgroundColor = .darkGrayColor()
c.titleColor = .lightGrayColor()
c.selectedTitleColor = .whiteColor()
c.bouncesOnChange = false

navigationItem.titleView = c

- 68747470733a2f2f6d656469612e67697068792e636f6d2f6d656469612f336f475246784145616f41416a716e5a36672f67697068792e676966 - #226: BetterSegmentedControl 🛠 – Little Bites of Cocoa

Awesome! More info about BetterSegmentedControl can be found at

Source link


Please enter your comment!
Please enter your name here