1. 设置占位图片以及文字颜色 字体大小
for (UIView *subViewin self.favoriteSearchBar.subviews)
{
for (UIView *secondLevelSubviewin subView.subviews){
if ([secondLevelSubviewisKindOfClass:[UITextFieldclass]])
{
UITextField *searchBarTextField = (UITextField *)secondLevelSubview;
//set font color here
searchBarTextField.textColor = [UIColorredColor];
searchBarTextField.font = [FontfontWithType:FontTypeFZLanTingHei_L_GBKsize:14];
//placeHolder文字设置
// UIColor *color = [UIColor whiteColor];
// searchBarTextField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"用户名" attributes:@{NSForegroundColorAttributeName: color}];
// [searchBarTextField setValue:[UIColorwhiteColor] forKeyPath:@"_placeholderLabel.textColor"];
break;
}
}
}
2. 设置背景颜色 也是第二层 subView
for (UIView *subview in searchBar.subviews)
{
for (UIView *sub in subview.subviews) {
if ([sub isKindOfClass:NSClassFromString(@"UISearchBarBackground")])
{
//选择清空或者 其他颜色
[sub removeFromSuperview];
break;
}
}
}
最后
以上就是哭泣朋友最近收集整理的关于设置 searchbar 的占位文字 以及 编辑文字的颜色和大小 背景颜色;的全部内容,更多相关设置内容请搜索靠谱客的其他文章。
发表评论 取消回复