An easy to use, customizable replacement for UISegmentedControl & UISwitch.
Switch branches/tags
Nothing to show
Clone or download
gmarm Merge pull request #86 from gmarm/xcode10
Xcode 10 - Swift 4.2 support
Latest commit 5d84656 Sep 24, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
Example Update breaking snapshot tests Sep 24, 2018
Pod Convert to Swift 4.2 Sep 24, 2018
.gitignore Updated Pods Oct 1, 2017
.swift-version Update .swift-version Sep 24, 2018
.travis.yml Initial commit Apr 3, 2016
BetterSegmentedControl.podspec Update podspec Sep 24, 2018
LICENSE Initial commit Apr 3, 2016
README.md Update README.md Jul 26, 2018
_Pods.xcodeproj Initial commit Apr 3, 2016
demo.gif Add files via upload Sep 17, 2016

README.md

BetterSegmentedControl

Version Carthage compatible License Platform

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

Demo

Features

  • Can be used as a segmented control or switch
  • Plethora of customizable options from colors to insets and radii
  • Use icons as segments, or add your own custom segments
  • Designable straight in Interface Builder
  • Customizable behavior

Requirements

  • iOS 8.0+
  • Xcode 7.3+

Installation

CocoaPods

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

Swift 4.x

pod 'BetterSegmentedControl', '~> 1.0'

Swift 3.x / Objective-C

pod 'BetterSegmentedControl', '0.8'

Carthage

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

Swift 4.x

github "gmarm/BetterSegmentedControl" ~> 1.0

Swift 3.x / Objective-C

github "gmarm/BetterSegmentedControl" 0.8

Manually

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

Usage

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),
              .indicatorViewBackgroundColor(.blue)])
control.addTarget(self, action: #selector(ViewController.controlValueChanged(_:)), for: .valueChanged)
view.addSubview(control)

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.

Contribution

Feel free to Fork, submit Pull Requests or send me your feedback and suggestions! Please make sure that tests are passing before submitting a new Pull Request.

Known Issues

  • CocoaPods version 1.5+ breaks IBDesignable support. If you need IBDesignable support stick to CocoaPods version 1.4 for now.

Author

George Marmaridis

License

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

I'd greatly appreciate it if you drop me a line if you decide using it in one of your apps.