|
1 | 1 | # TOSegmentedControl |
2 | | -A segmented control in the style of iOS 13 for previous versions of iOS. |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +[](https://buildkite.com/xd-ci/tosegmentedcontrol-run-ci) |
| 6 | +[](http://cocoadocs.org/docsets/TOSegmentedControl) |
| 7 | +[](https://github.com/Carthage/Carthage) |
| 8 | +[](https://raw.githubusercontent.com/TimOliver/TOSegmentedControl/master/LICENSE) |
| 9 | +[](http://cocoadocs.org/docsets/TOSegmentedControl) |
| 10 | +[](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=M4RKULAVKV7K8) |
| 11 | +[](http://twitch.tv/timXD) |
| 12 | + |
| 13 | +As part of the visual overhaul featured in iOS 13, `UISegmentedControl` was completely redesigned, featuring a much rounder, cleaner, and slightly more skeuomorphic appearance. |
| 14 | + |
| 15 | +`TOSegmentedControl` is a subclass of of `UIControl` that completely re-implements the look and feel of the new `UISegmentedControl` component, allowing developers to adopt its look even in previous versions of iOS they support. |
| 16 | + |
| 17 | +# Features |
| 18 | + |
| 19 | +* Recreates the new look of `UISegmentedControl`, making it available on previous versions of iOS. |
| 20 | +* Supports both text and images as segment types. |
| 21 | +* Configurable to dynamically add or remove items after its creation. |
| 22 | +* Written in Objective-C, but provides full compatibility with Swift. |
| 23 | +* Provides both a block, or `UIControlEvents` to receive when the control is tapped. |
| 24 | +* **(TODO)** A reversible mode where tapping the same item twice flips its direction. |
| 25 | +* **(TODO)** Light and dark mode support for iOS 13. |
| 26 | + |
| 27 | +# Sample Code |
| 28 | + |
| 29 | +`TOSegmentedControl` has been written to follow the interface of `UISegmentedControl` as closely as possible. This should make it very intuitive to work with. |
| 30 | + |
| 31 | +```Swift |
| 32 | + |
| 33 | +let segmentedControl = SegmentedControl(items: ["First", "Second", "Third"]) |
| 34 | +segmentedControlsegmentTappedHandler = { segmentIndex, reversed in |
| 35 | + print("Segment \(segmentIndex) was tapped!") |
| 36 | +} |
| 37 | +``` |
| 38 | + |
| 39 | +## System Requirements |
| 40 | +iOS 10.0 or above |
| 41 | + |
| 42 | +# Installation |
| 43 | + |
| 44 | +<details> |
| 45 | + <summary><strong>CocoaPods</strong></summary> |
| 46 | + |
| 47 | +Add the following to your Podfile: |
| 48 | +``` ruby |
| 49 | +pod 'TOSegmentedControl' |
| 50 | +``` |
| 51 | +</details> |
| 52 | + |
| 53 | +<details> |
| 54 | + <summary><strong>Carthage</strong></summary> |
| 55 | + |
| 56 | +1. Add the following to your Cartfile: |
| 57 | +``` |
| 58 | +github "TimOliver/TOSegmentedControl" |
| 59 | +``` |
| 60 | + |
| 61 | +2. Run `carthage update` |
| 62 | + |
| 63 | +3. From the `Carthage/Build` folder, import the `TOSegmentedControl.framework`. |
| 64 | + |
| 65 | +4. Follow the remaining steps on [Getting Started with Carthage](https://github.com/Carthage/Carthage#getting-started) to finish integrating the framework. |
| 66 | + |
| 67 | +</details> |
| 68 | + |
| 69 | +<details> |
| 70 | +<summary><strong>Manual Installation</strong></summary> |
| 71 | + |
| 72 | +All of the necessary source files located in the `TOSegmentedControl` folder. Simply drag that folder into your Xcode project. |
| 73 | +</details> |
| 74 | + |
| 75 | +# Credits |
| 76 | + |
| 77 | +`TOSegmentedControl` was created by [Tim Oliver](http://twitter.com/TimOliverAU) as a component for [iComics](http://icomics.co). |
| 78 | + |
| 79 | +iOS device mockup by [Pixeden](http://www.pixeden.com). |
| 80 | + |
| 81 | +# License |
| 82 | + |
| 83 | +`TOSegmentedControl` is available under the MIT license. Please see the [LICENSE](LICENSE) file for more information.  |
0 commit comments