簡體   English   中英

無法更改iOS 7搜索欄中的文本顏色

[英]Unable to change text color in a search bar for iOS 7

我需要更改UISearchBar文本字段中的文本顏色。 我在這篇文章中嘗試了兩個答案:

iOS 7中的UISearchBar文本顏色更改

但文本仍保持默認的灰色。 我在viewDidLoad方法中設置了該代碼。 我能錯過什么? 有人有同樣的問題嗎?

謝謝

[[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setTextColor:[UIColor blueColor]];

//This is done in Xcode 5.0 and its working btw i don't know whether it works with previous versions of Xcode or not....
// Also I wrote this method in viewDidLoad
// Get the instance of the UITextField of the search bar
UITextField *searchField = [self.searchBar valueForKey:@"_searchField"];

// Change search bar text color
searchField.textColor = [UIColor blueColor];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM