gpt4 book ai didi

objective-c - UITextField显示异常

转载 作者:行者123 更新时间:2023-11-30 12:51:54 26 4
gpt4 key购买 nike

我的viewController中有一个inputBar,带有一个textField和两个btns,它的布局如下:

enter image description here

橙色部分 View 是textField,两个btns我还没有设置它们的backgroundColor。

当我尝试连续输入一些单词,而内容已经超出了textField显示的范围时,左侧开关btn的位置会闪烁textField内容的一部分被遮挡。

这种情况只有在输入汉字时才会出现

这是我的 View 布局代码:

    self.backgroundColor = .lightGray
self.addSubview(switchBtn)
switchBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
switchBtn.setTitle("switch", for: .normal)
switchBtn.setTitleColor(.white, for: .normal)
switchBtn.snp.makeConstraints { (make) in
make.leading.equalToSuperview()
make.width.equalToSuperview().multipliedBy(1/8.0)
make.top.bottom.equalToSuperview()
}

self.addSubview(sendBtn)
sendBtn.titleLabel?.font = UIFont.systemFont(ofSize: 16)
sendBtn.setTitle("send", for: .normal)
sendBtn.setTitleColor(.white, for: .normal)
sendBtn.snp.makeConstraints { (make) in
make.width.equalTo(switchBtn)
make.top.bottom.trailing.equalToSuperview()
}
self.insertSubview(inputBar, at: 0)
inputBar.backgroundColor = .orange
inputBar.snp.makeConstraints { (make) in
make.leading.equalTo(switchBtn.snp.trailing)
make.top.equalToSuperview().offset(4)
make.bottom.equalToSuperview().offset(-4)
make.trailing.equalTo(sendBtn.snp.leading)
}

我用Objective-C写了同样的功能代码,也出现了同样的问题,你能告诉我问题出在哪里吗?

最佳答案

我没有你的其余代码,所以很难确定,但文本字段被设计为滚动。当剪辑 subview 关闭时,滚动到文本字段之外的内容仍然可见。

关于objective-c - UITextField显示异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40859853/

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