Latest 1.1
License MIT
Platforms ios 8.0

Table of Contents

Swift 4.0 Carthage compatible CocoaPods License MIT Build Status
License MIT [CocoaPods]()


AASegmentedControl is lightweight and easy-to-use customised segmented controls designed in vertical or horizontal directions, written in Swift. It allows the replacement of UISegmentedControl in iOS.



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


  • iOS 8.0+
  • Xcode 8.0+
  • Swift 3+


AASegmentedControl can be installed using CocoaPods, Carthage, or manually.


AASegmentedControl is available through CocoaPods. To install CocoaPods, run:

$ gem install cocoapods

Then create a Podfile with the following contents:

source ''
platform :ios, '8.0'

target '<Your Target Name>' do
pod 'AASegmentedControl' , '1.1'

Finally, run the following command to install it:

$ pod install


To install Carthage, run (using Homebrew):

$ brew update
$ brew install carthage

Then add the following line to your Cartfile:

github "EngrAhsanAli/AASegmentedControl" "master"

Then import the library in all files where you use it:

import AASegmentedControl

Manual Installation

If you prefer not to use either of the above mentioned dependency managers, you can integrate AASegmentedControl into your project manually by adding the files contained in the Classes folder to your project.

Getting Started

Create object of segmented control

Drag UIView object from the Object Library into your UIViewController in storyboard.


Set view object as segmented control

Set the view’s class to AASegmentedControl in the Identity Inspector.
Make sure the module property is also set to AASegmentedControl.


Customise the segmented control

You can customise the rating bar appearance in the Attributes Inspector.

Note: If storyboard does not show the stars click Refresh All Views from the Editor menu.


Set properties and usage

You can set following properties in viewDidLoad method in your view controller.


segmentControl.segmentTitles = // String array for titles
segmentControl.font = // Your font
segmentControl.selectedIndex = // Default selected index

// Add listener and observe changes!
segmentControl.addTarget(self, action: #selector(self.segmentValueChanged(_:)), for: .valueChanged)

func segmentValueChanged(_ sender: AASegmentedControl) {

// sender.selectedIndex is the selected index


Note that you can select or get the selected index by selectedIndex property.

Properties with description

You can use following properties:

Properties Types Description
segmentTitles [String] array of item names
font UIFont font for items with size
selectedIndex Int selected index of item
allowDamping Bool allow dampling animation for active view
activeUnderline Bool active underline or rectangle view
isHorizontal Bool horizontal or vertical direction
borderRadius CGFloat border radius
borderWidth CGFloat border width
borderColor UIColor border color
activeText UIColor active item text color
unactiveText UIColor unactive item text color
activeBg UIColor active item background color

Contributions & License

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

Pull requests are welcome! The best contributions will consist of substitutions or configurations for classes/methods known to block the main thread during a typical app lifecycle.

I would love to know if you are using AASegmentedControl in your app, send an email to Engr. Ahsan Ali

Latest podspec

    "name": "AASegmentedControl",
    "version": "1.1",
    "summary": "AASegmentedControl is lightweight and easy-to-use customised segmented controls, written in Swift.",
    "description": "AASegmentedControl is a lightweight and easy-to-use customised segmented controls designed in vertical or horizontal directions, written in Swift. It allows the replacement of UISegmentedControl in iOS.",
    "homepage": "",
    "screenshots": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Engr. Ahsan Ali": "[email protected]"
    "source": {
        "git": "",
        "tag": "1.1"
    "platforms": {
        "ios": "8.0"
    "source_files": "AASegmentedControl/Classes/**/*"

Pin It on Pinterest

Share This