Latest 0.0.2
Homepage https://github.com/BeckWang0912/DatePickerKit
License MIT
Platforms ios 9.0, requires ARC
Authors

CocoaPods
Platforms
License

DatePickerKit 是一个用于日期选择的管理工具,支持日期控件的系统风格和自定义风格,可设置最大最小时间、设置各种参数来实现不同风格的UI

Requirements

  • iOS 8.0+
  • Xcode 9.0+
  • Foundation
  • UIKit

Swift Versions

  • Swift 3.0+

Installation

You can use CocoaPods to install DatePickerKit by adding it to your Podfile:

pod 'DatePickerKit'

To get the full benefits import DatePickerKit wherever you import UIKit

import UIKit
import DatePickerKit

Manually

  1. Download and drop DatePickerKit.swift in your project.
  2. Congratulations!

Example

1.系统UI风格

    func datePickerTapped(actionPosition: ActionPosition, titile: String? = "") {
        let currentDate = Date()
        var dateComponents = DateComponents()
        dateComponents.month = -3
        let threeMonthAgo = Calendar.current.date(byAdding: dateComponents, to: currentDate)

        let datePicker = SystemDatePicker(title: titile,
                                          textColor: .black,
                                          buttonColor: .red,
                                          font: .boldSystemFont(ofSize: 17),
                                          showCancelButton: true,
                                          actionPosition: actionPosition,
                                          viewSize: nil,
                                          locale: Locale(identifier: "zh_CN"))

        datePicker.show(minimumDate: threeMonthAgo, maximumDate: currentDate, datePickerMode: .date) { [weak self] (date) in
            if let dt = date {
                let formatter = DateFormatter()
                formatter.dateFormat = "yyyy-MM-dd"
                if actionPosition == .center {
                    self?.vertifyBtn.setTitle(formatter.string(from: dt), for: .normal)
                }else{
                    self?.openBtn.setTitle(formatter.string(from: dt), for: .normal)
                }
            }
        }
    }

图片演示

image image

2.自定义UI风格

func customizeShow() {
        let picker = CustomizeDatePicker(datePickerStyle: .yearMonthDay, scrollToDate: Date()) { [weak self](date) in
            if let dt = date {
                let formatter = DateFormatter()
                formatter.dateFormat = "yyyy-MM-dd"
                self?.closeBtn.setTitle(formatter.string(from: dt), for: .normal)
            }
        }
        // 可自定义picker参数
        //picker.datePickerColor = .green
        //picker.maxLimitDate = Date()
        picker.show()
    }

图片演示

image

parameters

  具体可修改参数请移步代码查看

License

This code is distributed under the terms and conditions of the MIT license.

Latest podspec

{
    "name": "DatePickerKit",
    "version": "0.0.2",
    "summary": "u65e5u671fu9009u62e9u63a7u4ef6",
    "homepage": "https://github.com/BeckWang0912/DatePickerKit",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "description": "DatePickerKit u662fu4e00u4e2au7528u4e8eu65e5u671fu9009u62e9u7684u63a7u4ef6uff0cu53efu81eau5b9au4e49UIu98ceu683c",
    "authors": {
        "IMAC-AF9B8D": "[email protected]"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source": {
        "git": "https://github.com/BeckWang0912/DatePickerKit.git",
        "tag": "v0.0.2"
    },
    "source_files": "DatePickerKit/Sources/**/*",
    "requires_arc": true
}

Pin It on Pinterest

Share This