全网整合营销服务商

电脑端+手机端+微信端=数据同步管理

免费咨询热线:400-708-3566

IOS 开发之UIView动画的实例详解

IOS 动画实例详解

iOS动画的实现方式多种多样,这里就只记录一下 beginAnimations:context 。

在你调用 beginAnimations:context:方法来启动一个动画后,动画并不会立即被执行,直 到你调用 UIView 类的 commitAnimations 类方法。你对一个视图对象执行的介于 beginAnimations:context:方法跟 commitAnimations方法之间的操作(例如移动)会在 commitAnimations 被执行后才会生效 。

实现效果图:

代码很简单,直接贴了,如下:

// 
// ViewController.m 
// Graphics 
// 
// Created by aaron on 14b-5-29. 
// Copyright (c) 2014年 The Technology Studio. All rights reserved. 
// 
 
#import "ViewController.h" 
 
@interface ViewController () 
@property(nonatomic,strong) UIImageView *imageView1; 
@property(nonatomic,strong) UIImageView *imageView2; 
 
@end 
 
@implementation ViewController 
 
- (void)viewDidLoad 
{ 
  [super viewDidLoad]; 
   
  UIImage *image = [UIImage imageNamed:@"1.png"]; 
  self.imageView1 = [[UIImageView alloc] initWithImage:image]; 
  self.imageView2 = [[UIImageView alloc] initWithImage:image]; 
  [self.imageView1 setFrame:CGRectMake(0.0f, 
                     0.0f, 
                     100.0f, 
                     100.0f)]; 
   
  [self.imageView2 setFrame:CGRectMake(220.0f, 
                     350.0f, 
                     100.0f, 
                     100.0f)]; 
  [self.view addSubview:self.imageView1]; 
  [self.view addSubview:self.imageView2]; 
   
//  [self startTopLeftImageViewAnimation]; 
//  [self startBottomRightViewAnimationAfterDelay:2]; 
  [self affineTransformScaleAnimation]; 
  [self affineTransformRotateAnimation]; 
   
} 
 
//imageView2 animation 
-(void)startTopLeftImageViewAnimation{ 
  [self.imageView1 setFrame:CGRectMake(0.0f, 
                     0.0f, 
                     100.0f, 
                     100.0f)]; 
  [self.imageView1 setAlpha:1.0f]; 
  [UIView beginAnimations:@"imageView1Animation" context:(__bridge void*)self.imageView1]; 
  [UIView setAnimationDuration:3.0f]; 
  [UIView setAnimationDelegate:self]; 
  [UIView setAnimationDidStopSelector:@selector(imageViewDidStop:finished:context:)]; 
  [self.imageView1 setFrame:CGRectMake(220.0f, 350.0f, 100.0f, 100.0f)]; 
  [self.imageView1 setAlpha:0.0f]; 
  [UIView commitAnimations]; 
} 
 
-(void)imageViewDidStop:(NSString*)paramAnimationID finished:(NSNumber*)paramFinished context:(void*)paramContext{ 
  NSLog(@"AnimationID = %@\n",paramAnimationID); 
  UIImageView *contextImageView = (__bridge UIImageView *)(paramContext); 
  NSLog(@"contextImageView = %@",contextImageView); 
  [contextImageView removeFromSuperview]; 
} 
 
 
//imageView2 animation 
-(void)startBottomRightViewAnimationAfterDelay:(CGFloat)paramDelay{ 
  [self.imageView2 setFrame:CGRectMake(220.0f, 
                     350.0f, 
                     100.0f, 
                     100.0f)]; 
  [self.imageView2 setAlpha:1.0f]; 
  [UIView beginAnimations:@"imageView2Animation" context:(__bridge voidvoid *)(self.imageView2)]; 
  [UIView setAnimationDuration:3.0f]; 
  [UIView setAnimationDelay:paramDelay]; 
  [UIView setAnimationDelegate:self]; 
  [UIView setAnimationDidStopSelector:@selector(imageViewDidStop:finished:context:)]; 
  [self.imageView2 setFrame:CGRectMake(0.0f, 0.0f, 100.0f, 100.0f)]; 
  [self.imageView2 setAlpha:0.0f]; 
  [UIView commitAnimations]; 
} 
 
 
//imageView1 AffineTransformScale animation 
-(void)affineTransformScaleAnimation{ 
  self.imageView1.center = self.view.center; 
  self.imageView1.transform = CGAffineTransformIdentity; 
  [UIView beginAnimations:nil context:NULL]; 
  [UIView setAnimationDuration:5.0f]; 
  self.imageView1.transform = CGAffineTransformMakeScale(2.0f, 2.0f); 
  [self.imageView1 setAlpha:0.0f]; 
  [UIView commitAnimations]; 
} 
 
//imageView2 AffineTransformRotate animation 
-(void)affineTransformRotateAnimation{ 
  self.imageView2.center = self.view.center; 
  [UIView beginAnimations:@"clockwiseAnimation" context:NULL]; 
  [UIView setAnimationDuration:5.0f]; 
  [UIView setAnimationDelegate:self]; 
  [UIView setAnimationDidStopSelector:@selector(clockwiseRotationStopped:finished:context:)]; 
  self.imageView2.transform = CGAffineTransformMakeRotation(90.0f*M_PI/180.f); 
  [UIView commitAnimations]; 
} 
 
 
-(void)clockwiseRotationStopped:(NSString*)paramAnimationID finished:(NSNumber*)paramFinished context:(void*)paramContext{ 
  [UIView beginAnimations:@"counterclockwiseAnimation" context:NULL]; 
  [UIView setAnimationDuration:5.0f]; 
  self.imageView2.transform = CGAffineTransformIdentity; 
  [UIView commitAnimations]; 
} 
 
@end 

以上就是关于IOS动画开发的实例,本站对于IOS 开发还有很多教程,大家可以搜索查阅!


# IOS  # UIView动画  # 动画  # UIView  # Swift 2.1 为 UIView 添加点击事件和点击效果  # IOS UIView的生命周期的实例详解  # iOS动画-定时对UIView进行翻转和抖动的方法  # IOS自定义UIView  # 在uiview 的tableView中点击cell进入跳转到另一个界面的实现方法  # iOS为UIView设置阴影效果  # IOS 开发之swift中UIView的扩展使用的实例  # 才会  # 会在  # 很简单  # 到你  # 你对  # 多种多样  # 还有很多  # 方法来  # 贴了  # implementation  # viewDidLoad  # void  # UIImageView  # import  # reserved  # interface  # nonatomic  # property  # initWithImage  # setFrame 


相关文章: 建站之星安装需要哪些步骤及注意事项?  公司网站的制作公司,企业网站制作基本流程有哪些?  建站之星安装后界面空白如何解决?  国美网站制作流程,国美电器蒸汽鍋怎么用官方网站?  济南网站制作的价格,历城一职专官方网站?  相册网站制作软件,图片上的网址怎么复制?  公司门户网站制作公司有哪些,怎样使用wordpress制作一个企业网站?  股票网站制作软件,网上股票怎么开户?  学校建站服务器如何选型才能满足性能需求?  如何通过西部建站助手安装IIS服务器?  网站图片在线制作软件,怎么在图片上做链接?  建站之星在线版空间:自助建站+智能模板一键生成方案  如何登录建站主机?访问步骤全解析  安徽网站建设与外贸建站服务专业定制方案  北京专业网站制作设计师招聘,北京白云观官方网站?  北京营销型网站制作公司,可以用python做一个营销推广网站吗?  简历在线制作网站免费版,如何创建个人简历?  企业微网站怎么做,公司网站和公众号有什么区别?  已有域名如何快速搭建专属网站?  武清网站制作公司,天津武清个人营业执照注销查询系统网站?  如何在宝塔面板创建新站点?  如何高效利用200m空间完成建站?  c++ stringstream用法详解_c++字符串与数字转换利器  交易网站制作流程,我想开通一个网站,注册一个交易网址,需要那些手续?  网站好制作吗知乎,网站开发好学吗?有什么技巧?  如何优化Golang Web性能_Golang HTTP服务器性能提升方法  教程网站设计制作软件,怎么创建自己的一个网站?  胶州企业网站制作公司,青岛石头网络科技有限公司怎么样?  临沂网站制作公司有哪些,临沂第四中学官网?  如何挑选高效建站主机与优质域名?  北京建设网站制作公司,北京古代建筑博物馆预约官网?  零服务器AI建站解决方案:快速部署与云端平台低成本实践  如何快速搭建高效WAP手机网站吸引移动用户?  如何通过宝塔面板实现本地网站访问?  高性价比服务器租赁——企业级配置与24小时运维服务  深圳网站制作公司好吗,在深圳找工作哪个网站最好啊?  电影网站制作价格表,那些提供免费电影的网站,他们是怎么盈利的?  公司网站建设制作费用,想建设一个属于自己的企业网站,该如何去做?  大连网站设计制作招聘信息,大连投诉网站有哪些?  制作企业网站建设方案,怎样建设一个公司网站?  如何在Windows虚拟主机上快速搭建网站?  详解一款开源免费的.NET文档操作组件DocX(.NET组件介绍之一)  个人网站制作流程图片大全,个人网站如何注销?  建站VPS能否同时实现高效与安全翻墙?  如何构建满足综合性能需求的优质建站方案?  用v-html解决Vue.js渲染中html标签不被解析的问题  定制建站流程解析:需求评估与SEO优化功能开发指南  如何通过VPS搭建网站快速盈利?  如何用搬瓦工VPS快速搭建个人网站?  高性能网站服务器配置指南:安全稳定与高效建站核心方案 

您的项目需求

*请认真填写需求信息,我们会在24小时内与您取得联系。