动画的使用

来源:互联网 发布:淘宝企业店铺收费 编辑:程序博客网 时间:2024/06/06 07:20

1.使用UIView类函数实现:

  [UIView beginAnimations:@"animationID" context:nil];

  [UIView setAnimationDuration:0.5f];

  [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

 

       [UIView setAnimationTransition: UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];

         //UIViewAnimationTransitionFlipFromLeft,

    //UIViewAnimationTransitionFlipFromRight,

    //UIViewAnimationTransitionCurlUp,

    //UIViewAnimationTransitionCurlDown,

       //要执行的动作.

       [UIView commitAnimations];

 

2.使用CATransition对象来实现: //公开的API

 

    CATransition *animation = [CATransition animation];

    animation.duration = 0.5f;

    animation.timingFunction = UIViewAnimationCurveEaseInOut;

    animation.fillMode = kCAFillModeForwards;


    animation.type = kCATransitionPush;//kCATransitionMoveIn kCATransitionReveal kCATransitionFade

    animation.subtype = kCATransitionFromLeft;//kCATransitionFromRight kCATransitionFromTop  kCATransitionFromBottom

 

 

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

3.2.使用CATransition对象来实现: //末公开的API

    CATransition *animation = [CATransition animation];

    animation.delegate = self;

    animation.duration = 0.5f;

    animation.timingFunction = UIViewAnimationCurveEaseInOut;

    animation.fillMode = kCAFillModeForwards;

    animation.endProgress =1.0;

    animation.removedOnCompletion = NO;

 

    animation.type = @"cube";

     //@"suckEffect";@"oglFlip";@"rippleEffect";@"pageCurl";@"pageUnCurl";@"cameraIrisHollowOpen";@"cameraIrisHollowClose";


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

原创粉丝点击