Swift alternative of HMSegmentedControl by Hesham Megid. A drop-in replacement for UISegmentedControl mimicking the style of the segmented control used in Google Currents and various other Google products.
To run the example project, clone the repo, and run pod install
from the Example directory first.
- Swift 3 and above
- iOS 9 and above
TZSegmentedControl is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "TZSegmentedControl"
Please check code in Example Project to see how you can customize the TZSegmentedControl.
For creating a new TZSegmentedControl
let titleCont = TZSegmentedControl(sectionTitles: ["TRENDING","EDITOR'S PICKS", "FOR YOU", "VIDEOS", "LANGUAGE" ])
titleCont.frame = CGRect(x: 0, y: 50, width: self.view.frame.width, height: 50)
TZSegmentedControl also provide a block to be executed when selected index is changed. Alternativly, you could use addTarget:action:forControlEvents:
titleCont.indexChangeBlock = { (index) in
debugPrint("Segmented \(titleCont.sectionTitles[index]) is visible now")
}
tahseen0amin@gmail.com, tahseen0amin@gmail.com
TZSegmentedControl is available under the MIT license. See the LICENSE file for more info.
Thanks to Hesham Megid whose code in HMSegmentedControl was helpful.