Latest 0.3.0
License MIT
Platforms ios 9.0, requires ARC

license MIT
Build Status

A Swift picker view allows you to pick the titles you want and the date, time or dateTime in one view

ScreenShort & gif



TTADataPickerView is avaibale on CocoaPods.

  • 1 Insatll with CocoaPods:

    target 'MyApp' do
        pod 'TTADataPickerView'

    Then run a pod install inside you terminal

  • 2 Manually

    Clone the code from the github:

    git clone

    Then drop the TTADataPickerView folder to your project

    import TTADataPickerView


  • 1 Pick Data and date in one PickerView:

    You do not need to write UIDatePicker and UIPickerView

  • 2 Configurable apperance:

    You can configure the PickerView’s apperance as you want


  • 1 Initializer, you can configure the type and title

    let pickerView = TTADataPickerView(title: "TTADataPickerView", type: .text)
  • 2 Configure pickerView type with this property

    pickerView.type = .text

    Some Other type

    /// The component type of the TTADataPickerView
    public enum TTADataPickerViewType {
        /// pickerView default
        case text
        /// datePicker
        case date
        /// date and time
        case dateTime
        /// time
        case time
  • 3 Configure the delegate

    // You need to confirm `TTADataPickerViewDelegate`
    pickerView.delegate = self
  • 4 When the pickerView type is .text, configure this property to tell the pickerView what you want to select

    pickerView.textItemsForComponent = [["First", "Second", "Third", "Fourth", "Fifth", "Sixth", "Seventh", "Eighth", "Ninth", "Tenth"], ["First", "Second", "Third", "Fourth", "Fifth", "Sixth", "Seventh", "Eighth", "Ninth", "Tenth"], ["First", "Second", "Third", "Fourth", "Fifth", "Sixth", "Seventh", "Eighth", "Ninth", "Tenth"]]
  • 5 Show the PickerView
    or { 
       // something you want to do after show the pickerView
  • 6 Set the selectedTitles or selectedDate when the pickerView appers

  • 7 Configure the TTADataPickerView’s apperance

    // config the TTADataPickerView's apperance
    let apperance = TTADataPickerView.appearance()
    apperance.setConfirmButtonAttributes(att: [NSForegroundColorAttributeName:])
    pperance.setCancelButtonAttributes(att: [NSForegroundColorAttributeName:])
    apperance.setToolBarTintColor(color: .yellow)      apperance.setToolBarBarTintColor(color: .orange)
    apperance.setTitleFont(font: UIFont.systemFont(ofSize: 20))
    apperance.setTitleColor(color: .cyan)
  • 8 Delegate Functions

    // MARK: - TTADataPickerViewDelegate
    extension ViewController: TTADataPickerViewDelegate {
        // when the pickerView type is `.text`, you clicked the done button, you will get the titles you selected just now from the `titles` parameter
        func dataPickerView(_ pickerView: TTADataPickerView, didSelectTitles titles: [String]) {
            showLabel.text = titles.joined(separator: " ")
        // when the pickerView type is NOT `.text`, you clicked the done button, you will get the date you selected just now from the `date` parameters
        func dataPickerView(_ pickerView: TTADataPickerView, didSelectDate date: Date) {
            // actually you need configure the dateFormatter dateStyle and timeStyle to get the currect date from the `date` parameter
            if pickerView.type == .date {
                dateFormatter.dateStyle = .medium
            } else if pickerView.type == .time {
                dateFormatter.timeStyle = .medium
            } else if pickerView.type == .dateTime {
                dateFormatter.dateStyle = .medium
                dateFormatter.timeStyle = .medium
            showLabel.text = dateFormatter.string(from: date)
        // when the pickerView  has been changed, this function will be called, and you will get the row and component which changed just now
        func dataPickerView(_ pickerView: TTADataPickerView, didChange row: Int, inComponent component: Int) {
        // when you clicked the cancel button, this function will be called firstly
        func dataPickerViewWillCancel(_ pickerView: TTADataPickerView) {
        // when you clicked the cancel button, this function will be called at the last
        func dataPickerViewDidCancel(_ pickerView: TTADataPickerView) {

Latest podspec

    "name": "TTADataPickerView",
    "version": "0.3.0",
    "summary": "A Swift mixed data selector",
    "description": "A picker view allow you to pick the titles you want and the date, time or dateTime in one view!",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "TobyoTenma": "[email protected]"
    "platforms": {
        "ios": "9.0"
    "source": {
        "git": "",
        "tag": "0.3.0"
    "source_files": [
    "requires_arc": true,
    "pushed_with_swift_version": "3.0"

Pin It on Pinterest

Share This