PersianDatePicker written in Swift
- iOS 10.0+
- Xcode 10.3+
- Swift 5.0+
you can use in cocoapods
pod 'PersianDatePicker'
you can use in the storyboard, you add a UIView in your ViewController and inherit from [ PersianDatePickerView ]
you can use pickerStyle for two types .
persianDatePicker.style = .short
for set Font :
persianDatePicker.font = UIFont(name: "IRANSansMobileFaNum-Light", size: 18)
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.
PersianDatePicker is available under the MIT license. See the LICENSE file for more information.