https://github.com/bizz84/mvhorizontalpicker
Simple scrollable horizontal control, alternative to UISegmentedControl
https://github.com/bizz84/mvhorizontalpicker
Last synced: 6 months ago
JSON representation
Simple scrollable horizontal control, alternative to UISegmentedControl
- Host: GitHub
- URL: https://github.com/bizz84/mvhorizontalpicker
- Owner: bizz84
- License: mit
- Created: 2016-03-18T08:24:51.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-05-25T10:16:43.000Z (over 6 years ago)
- Last Synced: 2025-04-26T06:02:29.466Z (6 months ago)
- Language: Swift
- Size: 420 KB
- Stars: 43
- Watchers: 6
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# MVHorizontalPicker
MVHorizontalPicker is a simple scrollable horizontal control, alternative to UISegmentedControl.
[](http://mit-license.org)
[](https://developer.apple.com/resources/)
[](https://developer.apple.com/swift)
[](https://github.com/bizz84/MVHorizontalPicker/issues)
[](http://cocoadocs.org/docsets/MVHorizontalPicker/)## Preview

## Motivation
While `UISegmentedControl` is a good way of selecting amongst a few options, generally it has only space to show up to 5 values on iPhone portrait mode.
For larger option sets `UIPickerView` can be the right choice, however it also takes up more screen space.`MVHorizontalPicker` is the ideal UI control for choosing an item from up to a dozen possible values.
## Usage
```swift
class ViewController: UIViewController {@IBOutlet var picker: MVHorizontalPicker!
override func viewDidLoad() {
super.viewDidLoad()
picker.titles = [ "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday" ]
}@IBAction func pickerValueChanged(sender: AnyObject) { // Value Changed event
let title = picker.titles[picker.selectedItemIndex]
print("selected: \(title)")
}
}
```### Features
* Register to `UIControlEvents.ValueChanged` to check when the picker value has changed (same target/selector method used by `UISegmentedControl`).
* `@IBDesignable` properties for easier configuration in Interface builder
* Seamless integration in existing storyboards: Just drag a UIView, set the class type to `MVHorizontalPicker` and configure the presentation properties as needed.### Customisation
`MVHorizontalPicker` aims to be customisable. The following UI properties are currently supported:
* tintColor
* font
* itemWidth
* cornerRadius (IBInspectable)
* borderWidth (IBInspectable)### Auto-layout
`MVHorizontalPicker` is entirely built using auto-layout. As a result, it can be easily stretched to fit various widths and heights.
## Installation
MVHorizontalPicker can be installed as a Cocoapod and builds as a Swift framework. To install, include this in your Podfile.
```
use_frameworks!pod 'MVHorizontalPicker'
```Once installed, just import MVHorizontalPicker in your classes and you're good to go.
## Sample Code
A sample demo project is included to show how to use `MVHorizontalPicker`.
## License
Copyright (c) 2016 Andrea Bizzotto bizz84@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.