I am animating a resize of a UITextField
. I am using Autolayout with constraints. I have H:|-[textField] -(8)-[label]-(8)-[image]-|
in constraints in my storyboard.
I animate the label flying off screen, remove the constraint between the textField and the label, and then create a new constraint between the image and the textField.
When I animate view.layoutIfNeeded()
, the text inside the textField glitches into the top-left corner of the textField and then animates into its normal place.
Why is this happening and how can I stop it?
It's likely that you have pending layout operations other than the constraint you're talking about. Try calling layoutIfNeeded
once before you make the constraint changes, then add the constraints and call layoutIfNeeded
again inside the animation block.
This will ensure that only the constraint changes you intend to animate are actually animated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With