Reputation: 174
I am attempting to format an NSString which looks like:
"8. Juli 2016" (Locale is set as german - "de_DE")
Now i want to show picker with format like:
"juli 8 2106"
on the click of button action datepicker is open and it should display in label as default value.I have written code for it as below :
let dateFormatter = NSDateFormatter()
dateFormatter.locale = NSLocale(localeIdentifier: "de_DE")
dateFormatter.dateStyle = NSDateFormatterStyle.LongStyle
dateFormatter.dateFormat = "dd. MMMM yyyy"
let currentDateTime = NSDate()
strDob = dateFormatter.stringFromDate(currentDateTime)
lblFitnessRed.text=strDob
but picker should be shown in "MMMM dd yyyy" also it there any way to add custom fonts in date picker ?
Upvotes: 1
Views: 686
Reputation: 2285
UIDatePicker's date format depend on language set for a particular device in setting Or you set locale for date picker in application. If you want your own format then you need to use UIPicker with 3 components(Month, date and year) and set each label text as per your choice. Also you can set label font for your choice as well
Upvotes: 2