Swiftpack.co - Package - gmarm/BetterSegmentedControl


Version Carthage compatible License Platform

BetterSegmentedControl is an easy to use, customizable replacement for UISegmentedControl and UISwitch written in Swift.



  • ☑ Can be used as a segmented control or switch
  • ☑ Plethora of customizable options from colors to insets, radii, animations
  • ☑ Use text or icons as segments, or add your own custom segments
  • ☑ Designable straight in Interface Builder
  • ☑ Customizable behavior
  • ☑ Right-to-left languages support


  • iOS 9.0+
  • Xcode 8+


Swift Package Manager

BetterSegmentedControl is available through Swift Package Manager. To install it, simply go to Xcode under File > Swift Packages > Add Package Dependency...


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

# Swift 5.1
pod 'BetterSegmentedControl', '~> 1.3'

# Swift 4
pod 'BetterSegmentedControl', '1.0'

# Swift 3 / Objective-C
pod 'BetterSegmentedControl', '0.8'


If you prefer using Carthage, simply add BetterSegmentedControl to your Cartfile:

# Swift 5.1
github "gmarm/BetterSegmentedControl" ~> 1.3

# Swift 4
github "gmarm/BetterSegmentedControl" 1.0

# Swift 3 / Objective-C
github "gmarm/BetterSegmentedControl" 0.8


If you prefer not to use CocoaPods or Carthage, you can integrate BetterSegmentedControl into your project manually.


let control = BetterSegmentedControl(
    frame: CGRect(x: 0, y: 0, width: 300, height: 44),
    segments: LabelSegment.segments(withTitles: ["One", "Two", "Three"],
    normalFont: UIFont(name: "HelveticaNeue-Light", size: 14.0)!,
    normalTextColor: .lightGray,
    selectedFont: UIFont(name: "HelveticaNeue-Bold", size: 14.0)!,
    selectedTextColor: .white),
    index: 1,
    options: [.backgroundColor(.darkGray),
control.addTarget(self, action: #selector(ViewController.controlValueChanged(_:)), for: .valueChanged)

You can find different ways of using it (such as by designing it in a Storyboard file) in the example project. To run the example project, clone the repo, and run pod install from the Example directory first.


Feel free to submit Pull Requests or send me your feedback and suggestions!


George Marmaridis

  • https://github.com/gmarm
  • https://twitter.com/gmarmas
  • https://www.linkedin.com/in/gmarm
  • gmarmas@gmail.com


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


Stars: 1397


Used By

Total: 0


Swift Package Manager support and more! - 2019-11-10 12:59:26

  • You can now integrate BetterSegmentedControl via Swift Package Manager
  • Index change animation duration & damping are now customizable
  • Add convenient class variable for getting a control that resembles the native iOS 13 UISegmentedControl
  • Fix issue that was preventing shadows to be added for the indicator view
  • Fix issue with corner radius and indicator insets
  • Update for Swift 5.1
  • Minor formatting improvements here and there

Right to left languages support and more! - 2019-06-12 12:24:48

  • Right to left languages support
  • Number of lines now supported in label segments
  • Index is no longer UInt, but Int, like Apple recommends
  • Formatting fixes here and there
  • Minimum required iOS version bumped from 8.0 to 9.0

Images segments (and more) - 2018-07-22 15:49:02

This release adds support for any kind of segments. As a first addition, IconSegment has been added, in addition to the LabelSegment that was previously supported by default.

Additionally, tests have been completely rewritten and are now Snapshot tests.

Several minor usability and formatting updates.

Swift 4.0 - 2017-10-04 15:13:38

This release brings support for Swift 4.0 and a new way of configuration using enums for batch-configuring the control.

Indicator subviews, multiline titles - 2017-04-26 08:55:05

Adds more customizability options:

  • titleNumberOfLines controls the number of lines of the title labels
  • addSubviewToIndicator(_ view: UIView) adds subviews to the indicator view

Thanks to @amorde and @PoissonBallon for making this happen!

Customizable Borders - 2016-12-18 19:18:41

  • Adds 4 new public properties for customizing borders: indicatorViewBorderWidth, indicatorViewBorderColor, titleBorderWidth, titleBorderColor
  • Minor performance improvements
  • Formatting / naming improvements

Announces value immediately - 2016-12-17 18:45:29

  • Added property for announcing value immediately rather than waiting for animations to complete. This is now the default behavior.
  • Carthage shared scheme fix.

Swift 3.0 - 2016-09-14 14:27:03

Selected title font - 2016-06-26 14:42:56

Property selectedTitleFont was added.