如何检测用户是否点击了iOS键盘上的大写锁定按钮?
func textField(_ textField: UITextField, shouldChangeCharactersIn range: NSRange, replacementString string: String) -> Bool {
print(string)
return true
}textField中的文本更改将调用此方法。还有别的办法吗?
为什么我想知道大写锁定按钮是否被点击,是因为当用户点击大写锁定按钮时,我的右视图和苹果的大写锁定图标重叠。
发布于 2020-04-25 16:13:38
每当大写锁定打开时,iOS都会在UITextField的右侧显示shift-up符号。大写锁定图标基本上将设置在UITextField的rightView中,如果您看到视图层次结构的话。

因此,将rightView设置为UIView,并将frame设置为zero。
myTextField.rightView = UIView(frame: .zero)https://stackoverflow.com/questions/61379628
复制相似问题