1. 导航栏按钮添加图片使其保持原色
UIBarButtonItem *rightBarItem = [[UIBarButtonItem alloc] initWithTitle:nil style:UIBarButtonItemStylePlain target:self action:@selector(点击方法)];
self.navigationItem.rightBarButtonItem = rightBarItem;
[self.navigationItem.rightBarButtonItem setImage:[[UIImage imageNamed:@"图片"] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]]; 图像渲染模式总是显示原创
2.设置Cell的背景图片
cell.backgroundView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"图片"]];
3.searchBar的取消显示按钮 签订代理
- (void)searchBarCancelButtonClicked:(UISearchBar *)searchBar
{
[searchBar resignFirstResponder];
[searBar setShowsCancelButton:NOanimated:YES];
}
-(void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
[searBar setShowsCancelButton:YESanimated:YES];
//修改UISearchBar右侧的取消按钮文字颜色及背景图片
for(idsearchbuttonsin[[searchBar subviews][0] subviews])//只需在此处修改即可
if([searchbuttons isKindOfClass:[UIButton class]]) {
UIButton *cancelButton = (UIButton*)searchbuttons;
//修改文字颜色
[cancelButton setTitle:@"取消"forState:UIControlStateNormal];
[cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
[cancelButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
}
}