基本上我正在访问这个 URL
UITextField * textField= self.searchBar.textField;
假设函数 .textField 确实获取了 textField。我已经多次验证了这一点。
textField.adjustsFontSizeToFitWidth =true;
textField.minimumFontSize =10;
textField.enablesReturnKeyAutomatically =NO;
我跟着上面的代码。
当文本太长时,self.searchBar 中的 UITextField 仍然不会改变字体大小。
我想知道为什么。
最佳答案
试着让你的文本字段像这样....
UITextField *textField = [searchbar valueForKey:@"_searchField"];
And then customize it according to you.
textField.adjustsFontSizeToFitWidth =true;
textField.minimumFontSize =10;
textField.enablesReturnKeyAutomatically =NO;
关于ios - 如何更改 UISearchBar 中 UITextField 的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21745419/