ios-设置UISearchBar输入框的颜色等属性

xiaoxiao2021-02-28  136

我们其实都知道UISearchBar是UITextFiled和UISegmentedControl的组合和扩展,我们如果需要修改我们搜索栏里面的文本框的颜色,我们应该怎么修改呢,我们要修改搜索栏的placeholder的颜色又应该怎么修改呢?还有有一些普遍的属性具体看代码。 searchBar=[[UISearchBar alloc]initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 20)]; searchBar.placeholder=@"大家都在搜";//设置搜索框中带有的字体,一点击搜索框就会消失 searchBar.tintColor=[UIColor redColor];//设置光标的颜色  //searchBar.tintColor=[UIColor redColor];设置光标的颜色 UITextField *searchField=[searchBar valueForKey:@"searchField"]; searchField.backgroundColor = [UIColor colorWithRed:220.0/255.0 green:220.0/255.0 blue:220.0/255.0 alpha:0.3];//以此来设置搜索框中的颜色 //[searchField setValue:[UIColor blueColor]forKeyPath:@"placeholderLabel.textColor"];改变搜索框中的placeholder的颜色
转载请注明原文地址: https://www.6miu.com/read-28570.html

最新回复(0)