Animate UIView height from bottom to top

前端 未结 6 545
Happy的楠姐
Happy的楠姐 2021-02-02 17:35

I\'m doing a simple animation of UIView height so that it reveals.

By default it seems to be revealing from top to bottom, and I want it to reveal bottom to top.

<
6条回答
  •  情话喂你
    2021-02-02 18:16

    hide under bottom

    [self animateViewHeight:myView withAnimationType:kCATransitionFromBottom];
    

    for reverse animation

    [self animateViewHeight:myView withAnimationType:kCATransitionFromTop];
    

    ...

    - (void)animateViewHeight:(UIView*)animateView withAnimationType:(NSString*)animType {  
        CATransition *animation = [CATransition animation];
        [animation setType:kCATransitionPush];
        [animation setSubtype:animType];
    
        [animation setDuration:0.5];
        [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
        [[animateView layer] addAnimation:animation forKey:kCATransition];
        animateView.hidden = !animateView.hidden;
    }
    

提交回复
热议问题