博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
iOS 开发--动画
阅读量:4537 次
发布时间:2019-06-08

本文共 2325 字,大约阅读时间需要 7 分钟。

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.fillMide = 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];}

];}

];

转载于:https://www.cnblogs.com/wanghuaijun/p/5379255.html

你可能感兴趣的文章
HDMI转EDP芯片NCS8803简介
查看>>
Git查看、删除、重命名远程分支和tag
查看>>
nexus4/5/6/7/9/10设备谷歌安卓5.1.1系统底包下载
查看>>
子界类型的应用
查看>>
ubuntu系统中查看本机cpu和内存信息的命令和用法
查看>>
PHP的学习--cookie和session
查看>>
es6 箭头函数
查看>>
python装饰器的作用
查看>>
[bzoj2510]弱题 (循环矩阵优化dp)
查看>>
Django Form 的主要内置字段介绍
查看>>
如何写好一个UITableView
查看>>
XML文件生成C++代码(基于rapidxml)
查看>>
写代码,更需要设计代码
查看>>
iOS:修改项目名
查看>>
SpringCloud-Eureka
查看>>
double在输出为字符串的几种方法效率测试
查看>>
ArcGIS API for JavaScript 4.2学习笔记[14] 弹窗的位置、为弹窗添加元素
查看>>
电路基础
查看>>
jquery 对象与DOM对象转换
查看>>
DELPHI 调用系统 ADO 配置窗体 提高软件易用性
查看>>