Animating the display of a View

前端 未结 1 1653
春和景丽
春和景丽 2021-01-16 15:18

I have added a button on a view(the view is of the same size as the button). When that button is clicked a new view has to be displayed. So in the button\'s event handler I

相关标签:
1条回答
  • 2021-01-16 15:43

    Well you can animate the size of your window to simulate the slide from top like this:

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];
    myView.frame = CGRectMake(0, buttonHeight+buttonTop, myView.frame.size.width, viewTargetHeight);
    [UIView commitAnimations];
    

    Make sure you set the view height to 0 when you create it.

    To scroll it back up just do the opposite

    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3];
    myView.frame = CGRectMake(0, buttonHeight+buttonTop, myView.frame.size.width, 0);
    [UIView commitAnimations];
    

    If you actually want your new view to slide you can try animating both the size and the position and you'll also probably need to clip your animated view with another view.

    0 讨论(0)
提交回复
热议问题