我正在测试我的用户界面,我觉得搜索栏有点太狭隘了.我还想确保视力较差或手动灵巧较差的人在提出他们想要的界面方面没有任何问题.
所以,我想做的是调整UITextfield
内部的高度UISearchbar
.
我尝试过:1.在Storyboard中,添加UISearchbar
高度约束 - 结果:搜索栏大小增加,但UITextField
内部保持不变.
UITextField
内部UISearchbar
并修改其高度 - 结果:控制台输出显示参数已修改,但在屏幕上,UITextField
高度保持不变.注意 - 我可以修改UITextField
使用方法2的其他参数,并且更改会反映在屏幕上,所以我知道我正在使用UITextField
方法2的代码,放在UISearchbar所在的ViewController的viewDidLoad()中:
for tempView in (self.roomInfoSearchBar.subviews[0] as! UIView).subviews as! [UIView]
{
if let tV = tempView as? UITextField
{
var currentFrameRect = tV.frame
currentFrameRect.size.height = 80
//tV.layer.backgroundColor = UIColor.blueColor().CGColor //This works fine
//tV.layer.cornerRadius = 5 //This works fine
//tV.font = UIFont(name: "Courier", size: 40) //This works fine
println(tV.frame.height) //console output:0.0
tV.frame = currentFrameRect …
Run Code Online (Sandbox Code Playgroud)