0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

iOS26でUISearchBarのtext入力欄がグレーで表示されてしまう

Posted at

iOS26以上でアプリを起動すると、UISearchBarのテキスト入力欄が意図せずグレー背景で表示される問題が発生しました。

たとえば以下のようにsearchTextField.backgroundColorを設定しても、
検索バーのtextField部がグレーになってしまいます。

private lazy var searchTextField: UISearchBar = {
    let searchBar = UISearchBar()
    searchBar.backgroundColor = .white
    searchBar.searchTextField.backgroundColor = .white
    searchBar.backgroundImage = UIImage()
    searchBar.searchTextField.textAlignment = .left
    searchBar.searchTextField.tintColor = .blue
    searchBar.placeholder = "検索"
    return searchBar
}()

✅ 解決方法

以下のプロパティを設定する

searchBar.setSearchFieldBackgroundImage(UIImage(), for: .normal)

これでiOSのversionに依存せず同じ見た目で機能するかと思います👍

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?