ios - 如何更改 UISearchBar 中 UITextField 的属性

标签 ios objective-c ios7 uitextfield uisearchbar

基本上我正在访问这个 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/

相关文章:

ios - 为什么我不能为 CDTVC 中的私有(private) UIRefreshControl 属性创建 Getter?

ios - 使用 HMAC SHA1 的 CCKeyDerivationPBKDF 经常返回 -1

ios - 检查特定网络/SSID 是否可用

iphone - 动态禁用导航按钮和选项卡栏

ios - IOS 7.0 中 CFStream Socket 发送数据包不完整

ios - 在 UIImagePickerController 取消按钮不显示?

ios - 使用 HTML 文件初始化 NSAttributedString 将 HTTP 链接解析为文件 URL

ios - 评估类的方法或属性

ios - Shopify 购买 SDK : Maintain cart items between view controllers

ios - 是否可以在 Firebase 中使用电子邮件和电话号码进行身份验证?