我的viewController中有一个带有textField和两个btns的inputBar,它的布局如下:
橙色部分视图是textField,而我还没有将它们设置为backgroundColor。
这种情况只会出现在输入中文字符
中视图有我的布局代码:
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,它出现了同样的问题,你能告诉我我的问题在哪里吗?
答案 0 :(得分:0)
我没有剩下的代码,所以很难肯定,但文本字段是为了滚动而设计的。当剪辑子视图关闭时,在文本字段外滚动的内容仍然可见。