創(chuàng)建searchcontroller的方法就不多說了压昼,說一下修改對應(yīng)搜索框的顏色:
self.memberSearchVC.searchBar.barTintColor = [UIColor whiteColor]; // searchBar整個的背景色
for (UIView *subview in [[self.memberSearchVC.searchBar.subviews lastObject] subviews]) {
if ([subview isKindOfClass:[UITextField class]]) {
UITextField *textField = (UITextField*)subview;
// 搜索框里面的顏色
textField.backgroundColor = [UIColor colorWithRed:247/255.0 green:247/255.0 blue:247/255.0 alpha:1/1.0];
}
}