Skip to content

abbassabeti/PersianDatePicker

 
 

Repository files navigation

PersianDatePicker

PersianDatePicker written in Swift

Requirements

  • iOS 9.0+
  • Xcode 8.1+
  • Swift 3.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 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.

About

Persian Date picker

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Swift 94.7%
  • Ruby 2.9%
  • Objective-C 2.4%