UISearchBar设置背景颜色

2016-09-12  本文已影响0人  白日一山
@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;
}
上一篇下一篇

猜你喜欢

热点阅读