Skip to content

mobile-health/TZSegmentedControl

 
 

Repository files navigation

TZSegmentedControl

CI Status Version License Platform

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.

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • Swift 4.2 and above
  • iOS 10 and above

Installation

TZSegmentedControl is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "TZSegmentedControl"

Usage

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")
}

Screenshot

screenshot

Author

[email protected], [email protected]

License

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

Thanks

Thanks to Hesham Megid whose code in HMSegmentedControl was helpful.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 97.2%
  • Ruby 2.8%