0

To make "Cancel" button has bigger font on enlarged fonts (Setting->Accessibility) I modify UISearchBar

In general solution works like:

func searchBarTextDidBeginEditing(_ searchBar: UISearchBar) { searchBar.setShowsCancelButton(true, animated: true) if let cancelButton = searchBar.value(forKey: "cancelButton") as? UIButton { let attributedString = NSAttributedString( string: cancelButton.currentTitle ?? "", attributes: [.font: UIFontMetrics(forTextStyle: .body).scaledFont( for: BaseTextStyle(style: .body2) // Our custom font here, can be replaced with default .scaledFontModifier.uiFont )]) cancelButton.setAttributedTitle(attributedString, for: .normal) cancelButton.titleLabel?.lineBreakMode = .byWordWrapping cancelButton.titleLabel?.numberOfLines = 1 } } 

Problem that "Cancel" button or section for it does not get priority and stays in the smaller frame as for default size text. enter image description here

I assume I have to configure this button in another place (which?), or somehow change priorities in UISearchBar for sections.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.