简体   繁体   中英

UITextField text shift to the left by 1px when edited

In a right-aligned textfield, when it is edited, the text shift 1px to the left compared to the placeholder text's position. This doesn't happen on the simulator, only on a device (iPad in this case). Is this a known bug? Is there a way to fix to it?

There was a similar bug here but I am not using custom font, just a System font.

I've experienced this before and I think its actually an iOS bug. Anyway apple provides two methods you can override in UITextField. Hope it helps.

- (CGRect)textRectForBounds:(CGRect)bounds;
- (CGRect)placeholderRectForBounds:(CGRect)bounds;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM