IOS animates presentation including subviews

I am trying to make an animation to collapse a view that includes some subzones.

[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 fine, but only for aView. Subviews do not collapse as expected. How can I make objects hide? Also, is there a way to recalculate the original size after folding?

THX

+5
source share
3 answers

You may have forgotten to apply some autoresist mask to your subzones. If you do

for (UIView *subview in aView.subviews) {
    subview.autoresizingMask = (UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleBottomMargin | UIViewAutoresizingFlexibleTopMargin);
}

he should work.

BUT, personally, I would use, as the lamellas said.

aView.transform = CGAffineTransformMakeScale(1.0,0.0);
+5
source

Try using this for animation:

aView.transform = CGAffineTransformMakeScale(1.0,0.0);
+4
source

In-depth Assumption:

[UIView beginAnimations:@"advancedAnimations" context:nil];
[UIView setAnimationDuration:3.0];

CGRect aFrame = aView.frame;
aView.size.height = 0;
aView.frame = aFrame;

for (UIView *subview in aView.subviews) {
    CGRect frame = subview.frame;
    frame.size.height = 0;
    subview.frame = frame;
}

[UIView commitAnimations];

Also, is there a way to recalculate the original size after folding?

You probably want to just keep the height before folding.

0
source

All Articles