@interface CFControllerController:UITableViewController<UISearchDisplayDelegate,UISearchBarDelegate>{
UISearchBar*mySearchBar;
}
@end
- (void)viewDidLoad {
mySearchBar=[[UISearchBar alloc]initWithFrame:CGRectMake(0,20,self.view.width,44)];
//直接设置背景颜色会在页面展示动画没有结束的时候显示灰色
//mySearchBar.backgroundColor = [UIColor clearColor];
//所以使用:
UIImage* clearImg = [[UIImage alloc]init];
[mySearchBar setBackgroundImage:clearImg];
//因为光标时白色的
mySearchBar.tintColor= [UIColor blueColor];
mySearchBar.delegate=self;
[mySearchBarsetPlaceholder:@"请输入内容"];
self.navigationItem.titleView=mySearchBar;
}
网友评论