After IOS upgrade, the time control selected by the wheel will be invalid, uidatepicker

    2. If the previous style is used

 

datepicker.preferredDatePickerStyle = .wheels
    I don’t know if apple’s bug is wrong in both width and height

 

let datepicker = UIDatePicker(frame: CGRect(x: 0, y: 100, width: self.view.frame.width, height: 300))
 datepicker.preferredDatePickerStyle = .wheels  
 datepicker.backgroundColor = UIColor.yellow    
 datepicker.datePickerMode = .dateAndTime    
 self.view.addSubview(datepicker)


 
4. To fix this, set the frame after the datePickerMode and set it to normal
 

override init(frame: CGRect) {
        super.init(frame: frame)
        backgroundColor = .white
        
      

Read More: