Blog

iOS 14: Changes in UISearchBar

Curious how to handle the search bar of your mobile application after updating a device to iOS 14? This tutorial is for you.

The last time I wrote about the UISearchBar, 13 was the latest version of the iOS system.

iOS13 brought many changes in this view. Back then, I was showing you how to deal with them. Right now, with iOS 14, another change happened.

Although changes are minor this time around, you, as a mobile developer, should be aware of them. Let’s check out, what’s going on with UISearchBar and latest Apple mobile system!

UISearchBar in iOS14: What you should pay attention to

If you use a UISearchBar without any custom changes, there should be no problems. But if you do otherwise, you should check your app before its release. There are not so many changes when compared to iOS 13, so in most cases the transition to the latest OS should be easy.

But in my case wasn’t because of using dark mode in iOS.

UISearchBar in iOS14: Light and dark modes

As you propably know, using the dark and light modes in iOS can be tricky - especially when you forget to implement the colors used by an app.

In iOS 14, something changed with the color of the text you type in the Search Bar. In its previous versions, the font colors adjusted to tintColor. Or you could set it with the textFielddelegate:

searchBar.textField?.textColor = .white

But right now if you use UISearchBar with a dark background, that’s not enough. You should directly call UITextField inside your search bar. You can do it like this:

let textFieldInsideSearchBar = searchBar.value(forKey: "searchField") as? UITextField
textFieldInsideSearchBar?.textColor = .white

Wrapping up: UISearchBar and iOS 14 transition

With this change you can easily set the color of typed text. But remember: if your app is adjusted to the global dark/light theme, you should also implement the font color. This can be done with a special check or by using system colors provided by Apple. For example .systemFill or .label.

That’s all, I hope this little hack will help you with using UISearchBar in the latest iOS version.

Check our latest product - it's based on our experience of managing over 50-people strong company. The tool we're missing as a small company and not an enterprise.

humadroid.io is an employee and performance management software. It's an unique tool allowing everyone to be in the loop - by having up to date info about co-workers, time-off, benefits, assets, helping with one-on-ones, being a go-to place for company-wide announcements.

Check out humadroid.io
Top

Contact us

* Required fields

The controller of your personal data provided via this contact form is Prograils sp. z o.o., with a registered seat at Sczanieckiej 9A/10, 60-215 Poznań. Your personal data will be processed in order to respond to your inquiries and for our marketing purposes (e.g. when you ask us for our post-development, maintenance or ad hoc engagements for your app). You have the rights to: access your personal data, rectify or erase your personal data, restrict the processing of your personal data, data portability and to object to the processing of your personal data. Learn more.

Notice

We do not track you online. We use only session cookies and anonymous identifiers for the purposes specified in the cookie policy. No third-party trackers.

I understand
Elo Mordo!Elo Mordo!