您的位置:首页 > 产品设计 > UI/UE

UISearchBar

2015-12-23 10:23 471 查看
//修改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];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: