IOS开发中动画效果的示例

来源:爱站网时间:2020-12-26编辑:网友分享
在IOS开发中,相机快门都是由多张图片组成的效果,而程序员要实现这个效果会产生很大的工作量,下文是爱站技术频道小编和大家分享的IOS开发中动画效果的示例,一起参考看看吧!

在IOS开发中,相机快门都是由多张图片组成的效果,而程序员要实现这个效果会产生很大的工作量,下文是爱站技术频道小编和大家分享的IOS开发中动画效果的示例,一起参考看看吧!

 1.普通动画:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2];
frame.origin.x += 150;
[img setFrame:frame];
[UIView commitAnimations];

2.连续动画(一系列图像):

NSArray *myImages = [NSArray arrayWithObjects:
[UIImage imageNamed:@"myImage1.png"],
[UIImage imageNamed:@"myImage2.png"],
[UIImage imageNamed:@"myImage3.png"],
[UIImage imageNamed:@"myImage4.png"], nil];
UIImageView *myAnimatedView = [[UIImageView alloc] initWithFrame:[self bounds]];
myAnimatedView.animationImages = myImage;
myAnimatedView.animationRepeatCount = 0;
[myAnimatedView startAnimating];
[self addSubview:myAnimatedView];
[my AnimatedView release];

3.CATransition Public API:

CATransition *animation = [CATransition animation];
animation.duration = 0.5f;
animation.timingFunction = UIViewAnimationCurveEaseInOut;
animation.fillMode = KCAFillModeForwards;
//各种动画效果
/*
KCATransitionFade;
KCATransitionMoveIn;
KCATransitionPush;
KCATransitionReveal;
*/
/*
KCATransitionFromeRight;
KCATransitionFromLeft;
KCATransitionFormTop;
kCATransitionFromButtons;
*/
//各种组合
animation.type = KCATransitionPush;
animation.subtype = KCATransitionFromRight;
[self.view.layer addAnimation:animation forKey:@"animation"];

4.UIView Animations动画:

[UIView beginAnimations:@"animationID" context:nil];
[UIView setAnimationDuration:0.5f];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationRepeatAutoreverses:NO];
//以下四种效果
/*
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFormLeft forView:self.view cache:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFormRight forView:self.view cache:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
*/

5.嵌套使用,先变大再消失

[UIView animateWithDuration:1.25 aniamtions:^{
    CGAffineTransform newTRansform = CGAffineTransformMakeScale(1.2, 1.2);
    [firstImageView setTransform:newTransform];
    [secondImageView setTransform:newTransform];
    completion:^(BOOL finished){
        [UIView animateWithDuration:1.2 animations:^{
            [firstImageView setAlpha:0];
            [secondImageView setAlpha:0];
        }
        completion:^(BOOL finished){
            [firstImageView removeFromSuperview];
            [secondImageView removeFromSuperview];
        }
        ];
    }
];

以上就是关于IOS开发中动画效果的示例,大家在程序开发的时候经常会看到一些程序开发,可以参考模仿js.aizhan.com介绍的知识。

上一篇:IOS开发中像素对齐的详细简述

下一篇:IOS开发中使用图表框架绘制的操作步骤

您可能感兴趣的文章

相关阅读

热门软件源码

最新软件源码下载