AnimatedSegmentSwitch is a configurable multi-segment switch control written in Swift.
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.
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.
Please feel free to suggest any kind of improvements, refactorings, or just file an issue, fork and submit a pull request.
Tobias Schmid, toashd@gmail.com, @toashd, toashd.com
AnimatedSegmentSwitch is available under the MIT license. See the LICENSE file for more info.