I have this normal UIDatePicker
(sorry that it's not in English, please ignore that):
But the problem is that it only appears when I'm pressing the Date Picker:
And I wanted to know how to show the Date Picker like in the first image (that it's covering all the screen with the blur effect) only with code, so the user won't need to press the Date Picker to show the date selector. Thanks.
You can use a datePicker with .compact
style and put a UILabel
on top of it and give it a background color to hide the datePicker
behind it, and make sure the label user interaction is disabled then you should be able to tap on the datePicker and it will show the modal and then the value changed of the datePicker you can use your own date formatter to set the text of the label accordingly, you might also both the datePicker and the label inside a UIView
and make it clip to bounds
I have the same problem. Im using following hack:
let datePicker = UIDatePicker(frame: CGRect(x: 0, y: 0, width: 50, height: 50)) datePicker.preferredDatePickerStyle = .compact // Removes Labels datePicker.subviews.forEach({ $0.subviews.forEach({ $0.removeFromSuperview() }) })
Then I simply add this date picker on top of a view, which should open this popup.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With