Reputation: 291
I have a UITextField
that is using UIDatePicker
as an input. I set the Date Picker's style to be .inline
, but the result is not what I expected
As you can see, the hour selector in the Date Picker looks squashed.
This is my code:
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let datePicker = UIDatePicker()
datePicker.preferredDatePickerStyle = .inline
let textField = UITextField(frame: CGRect(origin: view.center,
size: CGSize(width: 60, height: 30)))
textField.text = "TEST"
textField.inputView = datePicker
self.view.addSubview(textField)
}
}
Is this a bug? am I missing something?
Upvotes: 19
Views: 7592
Reputation: 311
Try this:
if #available(iOS 13.4, *) {
datePicker.preferredDatePickerStyle = .wheels
}
Upvotes: 21