UISearchBar display bug: text too far left, overlapping the magnifying glass icon

萝らか妹 提交于 2019-12-04 07:01:10

That behavior can be caused by overriding either (CGRect)editingRectForBounds:(CGRect)bounds or - (CGRect)textRectForBounds:(CGRect)bounds. Have you altered either of those in a UITextField category elsewhere in your app? The purpose of doing that may have been to add padding to a text field (which can instead be accomplished with an invisible leftView). In this case, your custom "padding" is being applied to the UISearchBar text field.

Such a category on UITextField will also cause your app to crash while initializing framework classes that use UITextField, such as MFMailComposeViewController, so it is a bad idea for several reasons.

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