Can't change size of UISearchTextField since iOS 13

Viewed 508

Since iOS 13, I can't change the size of the UISearchBar text field. It seems that changing the searchTextField frame via the new API has no influence on the text field, even though the variable actually changes (visible in debugger & the other textfield moves).

This code works on iOS 12 and below, but not on iOS 13:

if #available(iOS 13.0, *) {
    let searchTextField: UISearchTextField = self.searchTextField
    searchTextField.frame = CGRect(x: 8, y: 4, width: self.frame.size.width - 20 - 148, height: 36)

    self.timeStampTextField.frame = CGRect(x: (searchTextField.frame.size.width) + 12, y: 10, width: 148, height: 36)
}
else {
    let searchField: UITextField? = self.value(forKey: "_searchField") as? UITextField
    searchField?.frame = CGRect(x: 8, y: 4, width: self.frame.size.width - 20 - 148, height: 36)

    self.timeStampTextField.frame = CGRect(x: (searchField?.frame.size.width ?? 300) + 12, y: 4, width: 148, height: 36)
}

How it looks on iOS 12 and below: enter image description here

How it looks on iOS 13 (not working): enter image description here

Any help is appreciated.

0 Answers
Related