简体   繁体   中英

Aligning text in the center after rotation

I am rotating the view and resizing and moving around UITextFields when this occurs. The only problem is that the placeholder text no longer stays in the middle. What should I do? Thanks!

This appears to be a bug with UIKit. This code was executed on rotation for both portrait and landscape:

textField.textAlignment = UITextAlignmentLeft; 
textField.textAlignment = UITextAlignmentCenter;

The text field's textAlignment property is moved to the left, then back to the center, almost refreshing it. If I try running the code without moving it to the left first, it doesn't work.

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