Latest 0.0.2
Homepage https://github.com/bizz84/MVHorizontalPicker
License MIT
Platforms ios 8.0, requires ARC
Authors

MVHorizontalPicker is a simple scrollable horizontal control, alternative to UISegmentedControl.

License
Platform
Language
Issues
Cocoapod

Preview

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

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 [email protected]

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.

Latest podspec

{
    "name": "MVHorizontalPicker",
    "version": "0.0.2",
    "summary": "Simple scrollable horizontal control, alternative to UISegmentedControl",
    "license": "MIT",
    "homepage": "https://github.com/bizz84/MVHorizontalPicker",
    "authors": {
        "Andrea Bizzotto": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/bizz84/MVHorizontalPicker.git",
        "tag": "0.0.2"
    },
    "source_files": "MVHorizontalPicker/*.{swift,xib}",
    "requires_arc": true
}

Pin It on Pinterest

Share This