UISearchBar setBarTintColor在ios6中无法识别的选择器异常

Shu*_*puS 0 objective-c ios

我在iOS6中有一个例外:

-[UISearchBar setBarTintColor:]: unrecognized selector sent to instance 0xad94250 
Run Code Online (Sandbox Code Playgroud)

但我的代码中没有这个方法.我怎么解决这个问题?

Bhu*_*tre 5

barTintColor可从iOS 7及更高版本获得,因此它仅适用于iO7及更高版本

@property(nonatomic,retain) UIColor *barTintColor NS_AVAILABLE_IOS(7_0) UI_APPEARANCE_SELECTOR;  // default is nil
Run Code Online (Sandbox Code Playgroud)

对于iOS 6.1及更低版本,您必须使用

@property(nonatomic,retain) UIColor *tintColor;
Run Code Online (Sandbox Code Playgroud)