I'm trying to make an animation for collapsing a view which includes some subviews.
[UIView beginAnimations:@"advancedAnimations" context:nil];
[UIView setAnimationDuration:3.0];
CGRect aFrame = aView.frame;
aView.size.height = 0;
aView.frame = aFrame;
[UIView commitAnimations];
This animation is doing fine, but for the aView only. Subviews doesn't collapse as expected. How do I make the subviews collapsing as well? Furthermore, is there a way to recalculate original size after collapsing?
THX
You have probably forgotten to apply some autoresizing mask to your subviews. If you do
for (UIView *subview in aView.subviews) {
subview.autoresizingMask = (UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin);
}
it should work.
BUT, personally I would use, as lamelas said
aView.transform = CGAffineTransformMakeScale(1.0,0.0);
Try using this to animate:
aView.transform = CGAffineTransformMakeScale(1.0,0.0);
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