Skip to content

farhad1985/PersianDatePicker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

37a32f6 · May 18, 2020

History

93 Commits
May 18, 2020
May 17, 2020
May 18, 2020
May 18, 2020
May 17, 2020
Nov 14, 2018
Feb 5, 2018
Aug 8, 2017
May 18, 2020
May 18, 2020

Repository files navigation

PersianDatePicker

PersianDatePicker written in Swift

Requirements

  • iOS 11.0+
  • Xcode 11.1+
  • Swift 5.0+

Install

you can use in cocoapods

pod 'PersianDatePicker'

StoryBoard

you can use in the storyboard, you add a UIView in your ViewController and inherit from [ PersianDatePickerView ]

Style

you can use pickerStyle for two types .

 persianDatePicker.style = .short

for set Font :

 persianDatePicker.font = UIFont(name: "IRANSansMobileFaNum-Light", size: 18)

How to use in the code

It's very simple.

import PersianDatePicker
@IBOutlet weak var txtDate: UITextField!
let persianDatePicker = PersianDatePickerView(frame: CGRect(x: 0, y: 0, width: 200, height: 200))
txtDate.inputView = persianDatePicker

persianDatePicker.onChange = { (year, month, day) in
    self.txtDate.text = "\(year)/\(month)/\(day)"
}

if you want to set years range:

persianDatePickerView.setYearsRange(fromYear : 1390 , toYear : 1400)

if you want to have persian date:

persianDatePickerView.getPersianDate()

and if you want to have gregorian date:

persianDatePickerView.getGregorianDate()

you can have next day or back day :

guard let persianDate = persianDatePickerView.getPersianDate() else {return}
self.persianDatePickerView.nextDay(by: persianDate)

if you want to use of dialog:

let pView = PersianDatePickerPresenter()
pView.show(in: self) { persianDate in
   print(persianDate)
}

please download example and test it.

License

PersianDatePicker is available under the MIT license. See the LICENSE file for more information.