0
votes

I've a UIView (call it notifications view) with a scrollView inside (using addSubView). I want to show this view as a popup with some animation. So in start I made its height as 0, and in animation block I set its height to desire number. When I want to hide this view, I set its height as 0 in animation block. Its working fine. The problem is

  • The child views of notification view appears first, then notification view completes its animation.
  • Same when I want to hide it, the notification view first completes its animation till height=0, then child views disappear at once.

I want to create the shrink/expand effect for notifications view. To show the popup, I'm using following animation block

[UIView animateWithDuration:1.0
                     animations:^{
                         notificationParentView.frame = CGRectMake(50, 52, 220, 200);
                         downArrowIcon.transform = CGAffineTransformMakeRotation(M_PI);
                     }];

To hide this popup, following piece of code runs

[UIView animateWithDuration:1.0
                     animations:^{
                         notificationParentView.frame = CGRectMake(50, 52, 220, 0);
                         downArrowIcon.transform = CGAffineTransformMakeRotation(0);
                     }completion:^(BOOL finished){
                         [notificationParentView removeFromSuperview];
                     }];

notificationParentView expands and shrinks well, but its child view aren't expanding/shrinking with their parent view .i.e.notificationParentView. Is there anything obvious I'm missing?

1

1 Answers

0
votes

You can use CGAffineTransform

//Appear animation
notificationParentView.transform = CGAffineTransformConcat(CGAffineTransformMakeScale(0, 1), CGAffineTransformMakeRotation(M_PI))    // Set to hidden state
[UIView animateWithDuration:1.0
                     animations:^{
                         notificationParentView.transform = GAffineTransformIdentity;// Set back to normal, displaying state
                     }];
//disappear
[UIView animateWithDuration:1.0
                     animations:^{
notificationParentView.transform = CGAffineTransformConcat(CGAffineTransformMakeScale(0, 1), CGAffineTransformMakeRotation(M_PI)); //Back to hidden state.                          
                         }];