Skip to content

toashd/AnimatedSegmentSwitch

Repository files navigation

AnimatedSegmentSwitch

AnimatedSegmentSwitch is a configurable multi-segment switch control written in Swift.

CI Status Version License Platform

AnimatedSegmentSwitch Screenshot

AnimatedSegmentSwitch Demo

Features

  • Up-to-date: Swift 3.0 (Xcode 8)
  • Support for Interface Builder
  • Supports multi-segments
  • Easy to use, lightweight, customizable and configurable
  • Works as UISegmentedControl and UISwitch drop-in replacement

Usage

import AnimatedSegmentSwitch

let segmentedSwitch = AnimatedSegmentSwitch()
segmentedSwitch.frame = CGRect(x: 50.0, y: 20.0, width: self.view.bounds.width - 100.0, height: 30.0)
segmentedSwitch.autoresizingMask = [.FlexibleWidth]
segmentedSwitch.backgroundColor = UIColor(red: 85.0/255.0, green: 172.0/255.0, blue: 238.0/255.0, alpha: 1)
segmentedSwitch.selectedTitleColor = UIColor(red: 85.0/255.0, green: 172.0/255.0, blue: 238.0/255.0, alpha: 1)
segmentedSwitch.titleColor = .whiteColor()
segmentedSwitch.font = UIFont(name: "HelveticaNeue-Medium", size: 13.0)
segmentedSwitch.thumbColor = .whiteColor()
segmentedSwitch.items = ["Week", "Month", "Year"]
segmentedSwitch.addTarget(self, action: "segmentValueDidChange:", forControlEvents: .ValueChanged)

view.addSubview(segmentedSwitch)

Alternatively the control's API can be easily configured via Interface Builder. For more code, open and run the sample project in Xcode.

Requirements

  • Xcode 8
  • Swift 3.0
  • iOS 8.0 or higher
  • ARC

Installation

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

pod "AnimatedSegmentSwitch"

You can also just drop AnimatedSegmentSwitch.swift into your project and start coding.

Contribution

Please feel free to suggest any kind of improvements, refactorings, or just file an issue, fork and submit a pull request.

Get in touch

Tobias Schmid, toashd@gmail.com, @toashd, toashd.com

License

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

About

Configurable multi-segment switch control written in Swift

Resources

License

Stars

Watchers

Forks

Packages

No packages published