UITextField text moving unexpectedly

匆匆过客 提交于 2019-12-23 03:28:10

问题


Below is a demonstration of how the text in my text field is moving when the text field is active. By applying a background to the field, i found that only the text moves, not the whole text field itself. This is not happening to the text field above as well, only the bottom one


回答1:


after search for this issue i recommend to change your font to another font. but there is some way to prevent this issue :

you can use this :

 - (void)textFieldDidEndEditing:(UITextField *)textField
{
 [textField layoutIfNeeded]; //Fixes iOS 9 text bounce glitch
  //...other stuff
}

please check this links :

Text in UITextField moves up after editing (center while editing)

UITextField text jumps iOS 9




回答2:


Try to change to font to Arial, helped me.

yourTextField.font = UIFont(name: "Arial", size: CGFloat(16))


来源:https://stackoverflow.com/questions/35680996/uitextfield-text-moving-unexpectedly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!