xcode 不值钱的动画UIImageView
了解 animateWithDuration方法 制作动画变得不值钱
代码创建一个UIImageView 后加入self.view 容器中
调用点击屏幕touchesBegan 方法执行动画
#import "ViewController.h" @interface ViewController ()
@property(nonatomic,weak)UIImageView * imgview; @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
CGFloat cgW=self.view.bounds.size.width;
CGFloat imgW=;
CGFloat imgH=;
CGFloat cgY=(cgW-imgW)*0.5; UIImageView * imgType=[[UIImageView alloc]init];
imgType.frame=CGRectMake(cgY, cgY, imgW, imgH);
imgType.image=[UIImage imageNamed:@"timg"];
imgType.contentMode=UIViewContentModeScaleAspectFill; self.imgview=imgType;
self.imgview.alpha=;//设置透明度
[self.view addSubview:self.imgview]; }
-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{ //动画1
// [self animationPlay1];
//动画2
// [self animationPlay2];
//动画3
// [self animationPlay3];
//动画4
[self animationPlay4];
} /**
动画一
向下滑动
并且消失
*/
-(void)animationPlay1{
/**
animateWithDuration:执行动画的时间
animations:执行的代码
*/
[UIView animateWithDuration:2.0 animations:^{
CGRect temp=self.imgview.frame;
temp.origin.y+=;
self.imgview.alpha=0.1;//设置透明度
self.imgview.frame=temp;
}];
}
/**
向下滑动然后回去
*/
-(void)animationPlay2{
/**
animateWithDuration:执行动画的时间
animations:执行的代码
completion:执行完代码的回调函数
*/
[UIView animateWithDuration:1.5 animations:^{
CGRect temp=self.imgview.frame;
temp.origin.y+=;
self.imgview.frame=temp; } completion:^(BOOL finished) {
CGRect temp=self.imgview.frame;
temp.origin.y-=;
self.imgview.frame=temp; }];
}
/**
向下滑动然后回去延迟1秒钟
*/
-(void)animationPlay3{
/**
animateWithDuration: 动画时间
delay:延迟时间
options:kNilOptions 这个一般设置为kNilOptions 也就是0
animations:要执行的动画代码
completion:回调函数
*/
[UIView animateWithDuration:1.5 delay:1.0 options:kNilOptions animations:^{
CGRect temp=self.imgview.frame;
temp.origin.y+=;
self.imgview.frame=temp;
} completion:^(BOOL finished) {
CGRect temp=self.imgview.frame;
temp.origin.y-=;
self.imgview.frame=temp;
}]; }
/**
放大图片
然后缩放回去
*/
-(void) animationPlay4{
CGFloat cgW=self.view.bounds.size.width;
// CGFloat cgH=self.view.bounds.size.height; CGFloat imgW=self.imgview.bounds.size.width;
CGFloat cgY=(cgW-imgW)*0.5;
[UIView animateWithDuration:1.5 animations:^{
CGRect temp=self.imgview.frame;
temp=CGRectMake(, cgY, self.view.bounds.size.width, self.view.frame.size.height-cgY);
self.imgview.frame=temp;
self.imgview.alpha=0.0;//设置透明度 } completion:^(BOOL finished) {
[UIView animateWithDuration:2.0 animations:^{
CGFloat cgW=self.view.bounds.size.width;
CGFloat imgW=;
CGFloat imgH=;
CGFloat cgY=(cgW-imgW)*0.5;
// CGRect temp=self.imgview.frame;
// temp=CGRectMake(cgY, cgY, imgW, imgH);
self.imgview.alpha=1.0;//设置透明度
self.imgview.frame=CGRectMake(cgY, cgY, imgW, imgH);
}];
}]; } @end
xcode 不值钱的动画UIImageView的更多相关文章
- xcode 不值钱的动画UIButton
#import "ViewController.h" @interface ViewController () /** 按钮 */ @property(nonatomic,weak ...
- xcode UIView常用方法属性动画
常见属性: @property(nonatomic,readonly) UIView *superview; 获得自己的父控件对象 @property(nonatomic,readonly,copy) ...
- UIImageView的animationImages动画
UIImageView的animationImages动画 UIImageView的animationImages,只有在做非常规动画的时候才有优势,比方说下图中左侧动画.如果用来做下图中的右侧动画, ...
- Xcode + Swift 制作动态原型
转载: Xcode + Swift 制作动态原型 为什么是 Xcode 和 Swift 我们尝试过的动态原型设计工具,Origami, Form, Hype, FramerJS,Pixate 等,但都 ...
- iOS - 开源框架、项目和学习资料汇总(动画篇)
动画 1. Core Animation笔记,基本的使用方法 – Core Animation笔记,基本的使用方法:1.基本动画,2.多步动画,3.沿路径的动画,4.时间函数,5.动画组.2. awe ...
- iOS开发UI篇—核心动画(UIView封装动画)
iOS开发UI篇—核心动画(UIView封装动画) 一.UIView动画(首尾) 1.简单说明 UIKit直接将动画集成到UIView类中,当内部的一些属性发生改变时,UIView将为这些改变提供动画 ...
- iOS UIView动画效果 学习笔记
//启动页动画 UIImageView *launchScreen = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds]; ...
- ios基础篇(二十五)—— Animation动画(UIView、CoreAnimation)
Animation主要分为两类: 1.UIView属性动画 2.CoreAnimation动画 一.UIView属性动画 UIKit直接将动画集成到UIView类中,实现简单动画的创建过程.UIVie ...
- UIImageView、UISlider、UISwitch、UIStepper、UISegmentControl
UIImageView——图像视图 作用:专门用来显示图片的控件 . 设置图像 [self.imageView setImage:[UIImage imageNamed:@"abc.png& ...
随机推荐
- Oracle EBS-SQL (AR-2):检查应收收款核销额
SELECT cust.customer_number, cust.customer_name, cash.receipt_number, gcc.segment1 || '.' ...
- CSS选择器、优先级和匹配原理
作为一个Web开发者,掌握必要的前台技术也是很重要的,特别是在遇到一些实际问题的时候.这里给大家列举一个例子: 给一个p标签增加一个类(class),可是执行后该class中的有些属性并没有起作用.通 ...
- 内核级HOOK的几种实现与应用
实现内核级 HOOK 对于拦截.分析.跟踪系统内核起着致关重要的作用.实现的方法不同意味着应用侧重点的不同.如想要拦截 NATIVE API 那么可能常用的就是 HOOK SERVICE TABLE ...
- C#/ASP.NET应用程序配置文件app.config/web.config的增、删、改操作
原文 http://www.cnblogs.com/codealone/archive/2013/09/22/3332607.html 应用程序配置文件,对于asp.net是 web.config,对 ...
- 轻奢当道业绩逆势增长 Kate Spade联手韩国衣恋开拓中国市场_商场报道_中国时尚品牌网
轻奢当道业绩逆势增长 Kate Spade联手韩国衣恋开拓中国市场_商场报道_中国时尚品牌网 轻奢当道业绩逆势增长 Kate Spade联手韩国衣恋开拓中国市场
- NET-A-PORTER为何难以模仿?_全文显示_生活福布斯中文网
NET-A-PORTER为何难以模仿?_全文显示_生活福布斯中文网 NET-A-PORTER为何难以模仿?
- python开发的一些tips
1. Notepad++编写python脚本 1)新建文件,编写代码 2)点击菜单栏,“语言”—>“P”—>“Python”,设置脚本为Python语言的高亮(这样保存文本的时候,Note ...
- 切点算法模板(Cut-vertex)
下面是一个模板被切割点,也cut_vertex_num[]排列(array)什么是切 - 点记录 Int cut_vertex_num[]; void dfs(int cur,int pa) { in ...
- inotify
inotify,文件系统控制函数,通知机制: ioctl, io控制函数
- sql server dateadd()
定义和用法 DATEADD() 函数在日期中添加或减去指定的时间间隔. 语法 DATEADD(datepart,number,date) date 参数是合法的日期表达式.number 是您希望添加的 ...