Reputation: 3071
- (IBAction)btnA:(id)sender {
if(self.height.constant == 300) {
self.height.constant = 50;
} else {
self.height.constant = 300;
}
[self.subView1 setNeedsUpdateConstraints];
[UIView animateWithDuration:1.0 animations:^{
[self.subView1 layoutIfNeeded];
}];
}
I am using this code but on iOS10
its not animating its just jump increasing and decreasing mySubview1 height. Why?
Same code is working fine in iOS9
Upvotes: 3
Views: 1644
Reputation: 2508
For iOS10 its the view's superview which you have to force layout.
//Force apply all constraints prior to the change in constant.
[self.view.superview layoutIfNeeded];
//Update constant
self.height.constant = 0;
[UIView animateWithDuration:1.0 animations:^{
[self.view.superview layoutIfNeeded];
}
I believe this behaviour is caused by the change in Xcode8 - iOS10 layout
References:
https://stackoverflow.com/a/39501882
https://stackoverflow.com/a/39548367/1045672
Upvotes: 9