ios UIView 动画效果

来源:互联网 发布:业务软件 编辑:程序博客网 时间:2024/05/13 01:49

用UIViewAnimation实现动画,代码如下:

    [UIView beginAnimations:@"animationID" context:nil];
    [UIView setAnimationDuration:1.0];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    [UIView setAnimationRepeatAutoreverses:NO];

   [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView: scrollView cache:YES];

   //还有这几种动画 : UIViewAnimationTransitionFlipFromLeft,UIViewAnimationTransitionCurlUp,UIViewAnimationTransitionCurlDown

   [scrollView bringSubviewToFront:[scrollView  viewWithTag:selectedIndex]];

    [UIView commitAnimations];


用CATransition实现动画,代码如下:

    CATransition *animation = [CATransition animation];

    animation.duration = 1.0;
    animation.timingFunction = UIViewAnimationCurveEaseInOut;
    animation.fillMode = kCAFillModeForwards;

    animation.type = kCATransitionMoveIn;//还有这几种动画:kCATransitionPush,kCATransitionReveal,kCATransitionFade
    animation.subtype = kCATransitionFromRight;//移动方向

   [self.view.layer addAnimation:animation forKey:@"animation"];


原创粉丝点击