Giter VIP home page Giter VIP logo

pickerbutton's Introduction

PickerButton

Platform Language Version Carthage compatible License

PickerButton is subclass of UIButton that presents UIPickerView in keyboard.

Concept

When PickerButton is tapped, it presents UIPickerView on UIKeyboard.

PickerButton inputView inputAccessoryView
PickerButton is in conformity to UIKeyInput. PickerButton returns UIPickerView as inputView. PickerButton returns UIToolBar as inputAccessoryView.

When selected row or component is changed, button title is automatically updated.

Usage

PickerButton is almost same interface as UIPickerView.

class ViewController: UIViewController {

    @IBOutlet weak var button: PickerButton!

    let pickerValues: [String] = ["first", "second", "third"]

    override func viewDidLoad() {
        super.viewDidLoad()

        button.delegate = self
        button.dataSource = self
    }
}

extension ViewController: UIPickerViewDelegate, UIPickerViewDataSource {

    func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
        return pickerValues[row]
    }

    func numberOfComponents(in pickerView: UIPickerView) -> Int {
        return 1
    }

    func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        return pickerValues.count
    }
}

To use PickerButton in Storyboard / Xib, set Custom Class to PickerButton.

Requirements

  • Swift 4.2
  • Xcode 10.1 or greater
  • iOS 10.0 or greater

Installation

CocoaPods

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

pod "PickerButton"

Carthage

If you’re using Carthage, simply add PickerButton to your Cartfile:

github "marty-suzuki/PickerButton"

Make sure to add PickerButton.framework to "Linked Frameworks and Libraries" and "copy-frameworks" Build Phases.

Author

marty-suzuki, [email protected]

License

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

pickerbutton's People

Contributors

lukedurrant avatar marty-suzuki avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

pickerbutton's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.