Coder Social home page Coder Social logo

aypopuppickerview's Introduction

AYPopupPickerView

A Popup PickerView or DatePickerView

Swift 5 CocoaPods Compatible Carthage compatible SPM Platform License

image

Installation

CocoaPods

pod 'AYPopupPickerView'

Carthage

github "Aiur3908/AYPopupPickerView"

Swift Package Manager

File -> Swift Packages -> Add Package Dependency

https://github.com/Aiur3908/AYPopupPickerView

Manually

Drag and drop Sources folder to your project.

Usage

AYPopupPickerView

let itemsTitle = ["Apple", "Avocado", "Banana", "Cherry", "Coconut", "Grape"]
let popupPickerView = AYPopupPickerView()
popupPickerView.display(itemTitles: itemsTitle, doneHandler: {
    let selectedIndex = popupPickerView.pickerView.selectedRow(inComponent: 0)
    print(itemsTitle[selectedIndex])
})

AYPopupDatePickerView

let popupDatePickerView = AYPopupDatePickerView()
popupDatePickerView.display(defaultDate: Date(), doneHandler: { date in
    print(date)
})

Custom

AYPopupPickerView

public var pickerView: UIPickerView!
public var doneButton: UIButton!
public var cancelButton: UIButton!
public var headerView: UIView!

AYPopupDatePickerView

public var datePickerView: UIDatePicker!
public var doneButton: UIButton!
public var cancelButton: UIButton!
public var headerView: UIView!

Example

let customPopupPickerView = AYPopupPickerView()
customPopupPickerView.headerView.backgroundColor = UIColor.green
customPopupPickerView.doneButton.setTitle("OK", for: .normal)
customPopupPickerView.doneButton.setTitleColor(.red, for: .normal)
customPopupPickerView.cancelButton.setTitleColor(.blue, for: .normal)
let customPopupDatePickerView = AYPopupDatePickerView()
customPopupDatePickerView.datePickerView.datePickerMode = .date

You can implementation UIPickerViewDataSource & UIPickerViewDelegate in your ViewController

class ViewController: UIViewController {
    
    let popupPickerView = AYPopupPickerView()

    override func viewDidLoad() {
        super.viewDidLoad()
        popupPickerView.pickerView.dataSource = self
        popupPickerView.pickerView.delegate = self
    }

    @IBAction func display(_ sender: Any) {
        popupPickerView.display(doneHandler: {
            
        })
    }
}

extension ViewController: UIPickerViewDataSource & UIPickerViewDelegate {
    func numberOfComponents(in pickerView: UIPickerView) -> Int {
        return 2
    }
    
    func pickerView(_ pickerView: UIPickerView, numberOfRowsInComponent component: Int) -> Int {
        return 5
    }
    
    func pickerView(_ pickerView: UIPickerView, titleForRow row: Int, forComponent component: Int) -> String? {
        return "\(row)"
    }
}

Author

Jerry You Email: [email protected]

LICENSE

MIT

aypopuppickerview's People

Contributors

aiur3908 avatar

Watchers

 avatar

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.