//修改UISearchBar取消按钮颜色
[[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:[NSArray arrayWithObjects:[UISearchBar class], nil]] setTitleTextAttributes:[NSDictionary dictionaryWithObject:[UIColor greenColor] forKey:NSForegroundColorAttributeName] forState:UIControlStateNormal];
UISearchBar * searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 6.0f, UI_SCREEN_WIDTH ,64.0f )];
searchBar.delegate = self;
searchBar.barStyle = UIBarStyleBlackTranslucent;
searchBar.backgroundColor = [UIColor clearColor];
searchBar.autocorrectionType = UITextAutocorrectionTypeNo;
searchBar.autocapitalizationType = UITextAutocapitalizationTypeNone;
searchBar.showsCancelButton = YES;
searchBar.placeholder = @"搜索";
// searchBar.tintColor = [UIColor clearColor];//COLOR_HEX(0x9A8316)
searchBar.keyboardType = UIKeyboardTypeDefault;
searchBar.returnKeyType = UIReturnKeySearch;
[searchBar setSearchFieldBackgroundImage:[IMG(@"input_discovery_search.png") resizableImageWithCapInsets:UIEdgeInsetsMake(10.0f, 20.0f, 10.0f, 20.0f) resizingMode:UIImageResizingModeStretch] forState:UIControlStateNormal];
[searchBar setImage:IMG(@"icon_discovery_search.png") forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal];
[searchBar setImage:IMG(@"icon_search_cancle.png") forSearchBarIcon:UISearchBarIconClear state:UIControlStateNormal];
UISearchBar
最新推荐文章于 2021-03-01 17:29:21 发布