ca动画
//动画上下文
-(void)animationOfUIKit
{
UIView *redView=[[UIView alloc]initWithFrame:CGRectMake(10, 10, 100, 100)];
redView.backgroundColor=[UIColor redColor];
[self.view addSubview:redView];
//开始动画
[UIView beginAnimations:@"test" context:nil];
//动画时长
[UIView setAnimationDuration:1];
/*
*要进行动画设置的地方
*/
redView.backgroundColor=[UIColor blueColor];
redView.frame=CGRectMake(50, 50, 200, 200);
redView.alpha=0.5;
//动画结束
[UIView commitAnimations];
}
//通过代码块
-(void)animationOfBlock
{
//初始化一个View,用来显示动画
UIView *redView=[[UIView alloc]initWithFrame:CGRectMake(10, 10, 100, 100)];
redView.backgroundColor=[UIColor redColor];
[self.view addSubview:redView];
[UIView animateWithDuration:1 //时长
delay:0 //延迟时间
options:UIViewAnimationOptionCurveEaseInOut//动画效果
animations:^{
//动画设置区域
redView.backgroundColor=[UIColor blueColor];
redView.frame=CGRectMake(50, 50, 200, 200);
redView.alpha=0.5;
} completion:^(BOOL finish){
//动画结束时调用
//............
}];
}
//CA动画
- (void)animationOfCABasicAnimation
{
//创建一个CABasicAnimation对象
CABasicAnimation *animation=[CABasicAnimation animation];
//设置颜色
animation.toValue=(id)[UIColor blueColor].CGColor;
//动画时间
animation.duration=1;
//是否反转变为原来的属性值
animation.autoreverses=YES;
//把animation添加到图层的layer中,便可以播放动画了。forKey指定要应用此动画的属性
[self.view.layer addAnimation:animation forKey:@"backgroundColor"];
}
//
//关键帧动画CAKeyframeAnimation
- (void)animationOfCAKeyframeAnimation
{
CAKeyframeAnimation *animation=[CAKeyframeAnimation animation];
//设置属性值
animation.values=[NSArray arrayWithObjects:
// (id)self.view.backgroundColor,
(id)[UIColor yellowColor].CGColor,
(id)[UIColor greenColor].CGColor,
(id)[UIColor blueColor].CGColor,nil];
animation.duration=3;
animation.autoreverses=YES;
//把关键帧添加到layer中
[self.view.layer addAnimation:animation forKey:@"backgroundColor"];
}
//使用路径制作动画CAKeyframeAnimation
- (void)animationOfCAKeyframeAnimationPath
{
//初始化一个View,用来显示动画
UIView *redView=[[UIView alloc]initWithFrame:CGRectMake(10, 10, 20, 20)];
redView.backgroundColor=[UIColor redColor];
[self.view addSubview:redView];
CAKeyframeAnimation *ani=[CAKeyframeAnimation animation];
//初始化路径
CGMutablePathRef aPath=CGPathCreateMutable();
//动画起始点
CGPathMoveToPoint(aPath, nil, 20, 20);
CGPathAddCurveToPoint(aPath, nil,
160, 30,//控制点
220, 220,//控制点
240, 380);//控制点
CGPathAddCurveToPoint(aPath, nil,
160, 30,//控制点
220, 220,//控制点
240, 380);//控制点
ani.path=aPath;
ani.duration=10;
//设置为渐出
ani.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
//自动旋转方向
ani.rotationMode=@"auto";
[redView.layer addAnimation:ani forKey:@"position"];
}
ca动画的更多相关文章
- iOS中 Animation 动画大全 韩俊强的博客
每日更新关注:http://weibo.com/hanjunqiang 新浪微博! iOS开发者交流QQ群: 446310206 1.iOS中我们能看到的控件都是UIView的子类,比如UIButt ...
- 【代码笔记】iOS-Transition动画
一,工程图. 二,代码. RootViewController.h #import <UIKit/UIKit.h> @interface RootViewController : UIVi ...
- iOS 动画效果:Core Animation & Facebook's pop
本文转载至 http://www.cocoachina.com/ios/20151223/14739.html 感谢原创作者分享 前言相信很多人对实现 iOS 中的动画效果都特别头疼,往往懒得动手,功 ...
- iOS之核心动画
.将动画的所有方法封装到一个类里面 MyCAHelper.h #import <Foundation/Foundation.h> #import <QuartzCore/Quartz ...
- iOS动画——CoreAnimation
CoreAnimation在我之前的UIKit动画里面简单的提了一句CoreAnimation动画,其实大家别看它类库名种有个animation,实际上animation在这个库中只占有很小的地位. ...
- iOS总结_UI层自我复习总结
UI层复习笔记 在main文件中,UIApplicationMain函数一共做了三件事 根据第三个参数创建了一个应用程序对象 默认写nil,即创建的是UIApplication类型的对象,此对象看成是 ...
- 史上最全的常用iOS的第三方框架
文章来源:http://blog.csdn.net/sky_2016/article/details/45502921 图像: 1.图片浏览控件MWPhotoBrowser 实现了一个照片 ...
- 常用iOS的第三方框架
图像:1.图片浏览控件MWPhotoBrowser 实现了一个照片浏览器类似 iOS 自带的相册应用,可显示来自手机的图片或者是网络图片,可自动从网络下载图片并进行缓存.可对图片进行缩放等 ...
- iOS_第3方类库_BlurAlertView_GPUImage
最终效果图: 先加入GPUImage.framework 导入BlurAlertView的类声明和类实现 // // BlurAlertView.h // 特效弹出框 // // Created by ...
随机推荐
- TypeScript 学习笔记(二)
块级作用域变量: 1.不能在被声明前读或写 console.log(num); let num: number = 0; // 报错 2.仍然可以在一个拥有块级作用域的变量声明前通过函数捕获它,但不能 ...
- 渗透测试学习 十八、 XSS跨站脚本漏洞详解 续
XSS平台搭建 ISS+zkeysphp 首先在IIS中新建一个网站,详细过程可以看我之前写搭环境的文章 (下面的写入选项不需要选中) 安装ZKEYS PHP 修改数据库配置 用户名:root 密码: ...
- RSA 登陆加密与解密
最近公司项目验收后,客户请来的信息安全技术人员对我们的网站进行了各种安全测试与排查问题,其中就有一个登陆时的加密问题.本来如果只是单纯的加密,可以直接在前台用MD5加密,将加密的值添加到数据库即可.但 ...
- 第16讲:ODBC&JDBC简介
一.ODBC简介 1. ODBC的概念 ①ODBC:Open DataBase Connection,即开放数据库连接 ②ODBC是一种标准,它规定了不同语言的应用程序与不同数据库服务器之间通讯的方式 ...
- KMP算法计算next值和nextVal值
KMP算法: 给定一个主串S及一个模式串P,判断模式串是否为主串的子串:若是,返回匹配的第一个元素的位置(序号从1开始),否则返回0: 这里先不写算法,仅仅计算next和nextVal值 那么计算时只 ...
- CME Futures & Options Order Book
http://algo-logic.com/futures-options-orderbook Algo-Logic Systems’ Futures & Options (F&O) ...
- Paper | Compression artifacts reduction by a deep convolutional network
目录 1. 故事 2. 方法 3. 实验 这是继SRCNN(超分辨)之后,作者将CNN的战火又烧到了去压缩失真上.我们看看这篇文章有什么至今仍有启发的故事. 贡献: ARCNN. 讨论了low-lev ...
- [转]python 中的[:-1]和[::-1]
转自:https://blog.csdn.net/mingyuli/article/details/81604795 1.案例解释a='python'b=a[::-1]print(b) #nohtyp ...
- csps2019记
Day0: 上午疯狂颓板子(树状数组,KMP)屁都没考,感觉海星. 上午坐大巴去了德州,中午和skyh凑钱吃饭(其实是我请他)rp++. 下午在火车上和侯神打扑克,拉火车之神Get. 到燕大试机,敲了 ...
- k8s 二进制部署详解
环境说明: 192.168.1.101 -- master01 + etcd01 192.168.1.102 -- etcd02 192.168.1.103 -- etcd03 192.168.1.1 ...