Changing UIDatePicker - ios

I want to make a datePicker like the one in picture given below:
By UIDatePicker, as long I searched I think UIDatePicker doesn't provide this view. So, I have designed the above view by UIPickerView but my code is very messy and there are other requirements too with the picker now. Can you suggest some library for it?

using a UIDatePicker it is possible by changing the datePickerMode property:
datePicker.datePickerMode = UIDatePickerModeDateAndTime;
More on the documentation
Also, if you want to change the order, you can set the localeproperty with a locale that has a different date format.

Related

How to set custom date display on UIDatePicker?

I have added a UIDatePicker from storyboard. By default picker shows me the date format as (October - 26 - 2017). But i want the format to be dispayed as (26 - 10 - 2017 ).I am not able to display date in this format on UIDatePicker.Please tell me how can i do this?
You can't do this.
From Apple's documentation for: UIKit > Views and Controls > UIDatePicker
Appearance
The appearance of UIDatePicker is not customizable.
The only thing Apple allows you to change is the date picker mode, which is not what you want. To change the layout to "dd-mm-yyyy", you will need build your own customized picker.
The way I'd suggest going about this, is instead of using UiDatePicker, to use UIPicker. Then, create and assign to that picker a unique class, which inherits from UIPickerView. This way you can customize it exactly how you want. Here is a helpful link for how to get all dates between a range (which is how UIDatePicker() is populated) - Swift: Print all dates between two NSDate()

UIDatePicker Shows Empty Picker view

UIDatePicker Shows Empty Picker View. It's working perfect, I mean It is scrolling, It is setting date to respective textfield but in picker view it is not displaying date. I have attached a screenshot.
Code for DatePiker,
datePicker = [[UIDatePicker alloc]init];
datePicker.datePickerMode = UIDatePickerModeDateAndTime;
[datePicker setDate:[NSDate date]];
_txtDue.inputView = datePicker;
Any help will be appreciated!
Finally I figure out it. It was a issue of one third party library called UIHidingView!! It was added by someone in this project. This library's description from github states that,
UIHidingView is an iOS class that displays UIView element on top UITableView which is hiding when Table View is scrolling
Now UIDatePicker internally used tableview in it so, it was hiding it's components!
PS : take care when using third party libraries!!

How to Create a UITextField to accommodate value in this following manner?

I am developing an ios application that has two input fields that for entering date. I am planning to add a UIDatePicker in the following manner
[_datePicker setFrame:CGRectMake([UIScreen mainScreen].bounds.size.width-_datePicker.bounds.size.width, [UIScreen mainScreen].bounds.size.height-_datePicker.bounds.size.height, _datePicker.frame.size.width, _datePicker.frame.size.height)];
_inputText.inputView=_datePicker;
But the bigger problem is, I need it to look something like the image I have posted
How can I accomplish this?
Okay... there should be a couple ways to solve this.
1)
Put a transparent (or clear colored) UIButton over the view with the date labels. You may need to make the view containing the labels change color/alpha something to indicate the button has been touched before bringing up the date picker.
2)
If the above doesn't work, try adding the view with the labels as a subview into UIButton.

Disable / Enable UIDatepicker

Is there any disable/enable function in Xcode, i have already tried the hidden function but that really doesn't suit my needs. I'm trying to turn off my UIDatepicker if a uiswitch has been toggled and if it isn't toggled i want it shown. hiding this still outputs todays date to my mail composer. Is there anyway to do this?
Make sure you have a property (IBOutlet) for your UIDatepicker in your .h file
then you can simply do like this:
DatePickerNamed.userInteractionEnabled = YES;
DatePickerName.userInteractionEnabled = NO;
In addition to that I also turn down the alpha value for buttons and switches, if I disable them, so there is also a visual feedback that they're inactive.

UIDatePicker show only picker like Sleep Cycle

I would like to add a UIDatePickerModeTime picker, but the grey area around it seems so ugly to me. I am just wondering what's the best way of removing it? Is there some property I can set or any frame reset?
!
Well, I know one of the way to do it would be
Place the picker below a "background" image, which hides everything but the picker itself
Well, in that case you can create your own custom date picker with UIPickerView.
This link might help you.

Resources