i am working to animate a uiview(parent view named 'popupVw') which contains 11 subviews (7 buttons,2 labels,2 imageview). Initially the the frame size is :
CGRect Frame = CGRectMake(10, 10 ,320, 0);
& new frame size is:
CGRect newFrame = CGRectMake(10, 10 ,320, 300);
[UIView animateWithDuration:0.5
animations:^{popupVw.frame = newFrame;}
completion:^(BOOL finished){
// do stuff here after animation finished
}];
So basically i am changing the height of view from 0 to 300 . & then from 300 to 0 again. to achieve show hide animation.
Consider it as a popup in the middle of the screen appearing from 0 to 300 height . This popup contains subviews & a close button at the top right corner. By clicking this close button the popup again decreases to height from 300 to 0. parent popup view is animating correctly. But the subviews are visible before the height increases to maximum. & visible till the height of parent view goes to 0 again. So basically only the parent view is animating & not the inner view.
The animation is working properly on parent view but the subviews are not animating with the parent view. As a result when i change the height of uiview from 300 to 0 then all the subviews still visible & only the parent uiview's height become 0.
Do i need to put animation for them seperately? if yes then how can i do this for the height change ? Or is there any other approach which i can use to achieve the same result?
i tried autoresizing mask . but its not working for me :
pointerImgVw.autoresizingMask = UIViewAutoresizingFlexibleBottomMargin ;
Below are the srceengrabs of the problem :
The cross button at the top right corner is subview of the animating popup. What i want is the cross button should not be outside of the animating view. For example in the 2nd screenshot only the half cross button should be visible.outside part should not be visible
Set the clipsToBounds property of the parent view to YES
i.e parentView.clipsToBounds=YES