我正在使用外观API自定义UISearchBar
[[UISearchBar appearance] setSearchFieldBackgroundImage:searchBackground forState:UIControlStateNormal];
[[UISearchBar appearance] setBackgroundImage:backgroundImage];
[[UISearchBar appearance] setScopeBarBackgroundImage:backgroundImage];
[[UISearchBar appearance] setBackgroundColor:[UIColor clearColor]];
我在作为其他类的父类的类中使用此方法,以便在所有子类上实现效果。
现在,我需要自定义包含
UISearchBar
的子类之一。我尝试了link但是在 super class 上完成外观时,我无法获得那种效果。如果删除外观,则可以实现此效果。
如何通过实现外观 API来做到这一点?
最佳答案
[[UISearchBar appearanceWhenContainedIn:[yourSubClassedViewControllerWhichHasSearchbar class], nil]
setBackgroundColor:[UIColor orangeColor]];