UIView animation frames are getting affected after assigning text to UILabel in iOS?

I added below animations to UIView


[UIView animateWithDuration:0.2 delay:0 options:(UIViewAnimationOptionTransitionNone) animations:^{

self.topView.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - 100); self.mapview.frame = CGRectMake(0, self.upperviewOnMap.frame.origin.y+self.upperviewOnMap.frame.size.height, self.view.frame.size.width, self.topView.frame.size.height - (self.upperviewOnMap.frame.size.height + 96)); self.bottomContainerView.frame = CGRectMake(0, self.view.frame.size.height - 100, self.view.frame.size.width, 50); [self hideTheFavouriteTableView];

}completion:^(BOOL finished) {

self.mapview.frame = CGRectMake(0, self.upperviewOnMap.frame.origin.y+self.upperviewOnMap.frame.size.height, self.view.frame.size.width, self.topView.frame.size.height - (self.upperviewOnMap.frame.size.height + 96));

}];


In autolayout I added UILabel(currentLocationLabel) as a subview to self.topview and after getting reverse geocoding of current location I am assigning that location name to this

Eg:currentLocationLabel.text = @"California";


Once I assigned text to this label, automatically above added animation views frames getting changed.

If I have not assigned any text to the currentLocationLabel then no issues. But I have to assign text to the UILabel.

Changing a UILabel's text will trigger a layout pass. If you're using auto layout, you can't position things by setting their frame or center properties. Anything that triggers layout (rotation, appearance of double height status bar, changing a label's text as you've noticed, etc.) will cause auto layout to reset their frames to the values determined by constraints. If using auto layout you have to animate the constraints, not the frame or center.

UIView animation frames are getting affected after assigning text to UILabel in iOS?
 
 
Q