gpt4 book ai didi

ios - 在默认 UIsearchBar 中更改 UITextField 的高度

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:31:07 28 4
gpt4 key购买 nike

我正在使用默认搜索栏,并尝试使用以下行更改搜索栏的高度,

for subView in search_bar.subviews
{
for subsubView in subView.subviews
{
if let textField = subsubView as? UITextField
{
textField.borderStyle = .roundedRect
// var frameRect = textField.frame;
//frameRect.size.height = 100; // <-- Specify the height you want here.
// textField.frame = frameRect;
textField.frame = CGRect(x: 0, y: 0, width: self.view.frame.width, height: 70)
//textField.font = UIFont.systemFont(ofSize: 20)
}
}
}

它似乎不起作用...有人可以帮忙吗?

最佳答案

使用此代码即可:

for subView in search_bar.subviews where subView is UITextField {
subView.frame = CGRect(x: 0, y: 0, width: subView.frame.size.width, height: 70)
}

关于ios - 在默认 UIsearchBar 中更改 UITextField 的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47052387/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com