UISearchBar cancel button color?

前端 未结 11 647
耶瑟儿~
耶瑟儿~ 2020-12-13 09:00

When I drop a UISearchBar into my view inside Interface Builder, and change its style to Black Opaque, the cancel button stays unfittingly blue / gray and doesn\'t become bl

11条回答
  •  难免孤独
    2020-12-13 09:30

    In Swift 4.2

    let appearance = UIBarButtonItem.appearance(whenContainedInInstancesOf: [UISearchBar.self])
    appearance.setTitleTextAttributes([NSAttributedString.Key.foregroundColor: UIColor(named: "goldColor")!], for: .normal)
    

    This works for me. Thanks @Tim Semple

提交回复
热议问题