iOS Layer CABasicAnimation
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
CALayer *layer = [CALayer layer];
layer.delegate = self;
layer.bounds = CGRectMake(0, 0, 100, 100);
layer.position = CGPointMake(100, 100);
layer.anchorPoint = CGPointZero;
layer.backgroundColor = [UIColor blackColor].CGColor;
[layer setNeedsDisplay];
[self.view.layer addSublayer:layer];
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx
{
CGContextSetRGBFillColor(ctx, 1.0, 0, 0, 1.0);
CGContextAddRect(ctx, CGRectMake(0, 0, 20, 20));
CGContextFillPath(ctx);
}
CABasicAnimation *basicAnimation = [CABasicAnimation animation];
basicAnimation.keyPath = @"position";
basicAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(0, 0)];
basicAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(200, 200)];
basicAnimation.duration = 1.0;
basicAnimation.removedOnCompletion = NO;//动画执行完以后不要删除动画
basicAnimation.fillMode = kCAFillModeForwards;//保持最新的状态
[self.layer addAnimation:basicAnimation forKey:nil];
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css);@import url(/css/cuteeditor.css);
iOS Layer CABasicAnimation的更多相关文章
- ios之CABasicAnimation
博主:最近iOS开发中用到CoreAnimation的framework来做动画效果,虽然以前也用过,但一直没有系统学习过,今天看到一篇非常详细的博文(虽然是日语,但真的写的很好),在此翻译出来供大家 ...
- iOS开发CABasicAnimation动画理解
1.CALayer简介 CALayer是个与UIView很类似的概念,同样有backgroundColor.frame等相似的属性,我们可以将UIView看做一种特殊的CALayer.但实际上UIVi ...
- ios layer 动画-(transform.rotation篇)
x轴旋转: CABasicAnimation *theAnimation; theAnimation=[CABasicAnimation animationWithKeyPath:@"tra ...
- IOS Layer的使用
CALayer(层)是屏幕上的一个矩形区域,在每一个UIView中都包含一个根CALayer,在UIView上的所有视觉效果都是在这个Layer上进行的. CALayer外形特征主要包括: 1.层的大 ...
- ios layer 动画
#import "ViewController.h" @interface ViewController (){ CALayer *_l1;//定义能够全局使用 CAL ...
- iOS开发基础知识:Core Animation(核心动画)
Core Animation,中文翻译为核心动画,它是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事半功倍.也就是说,使用少量的代码就可以实现非常强大的功能. Core A ...
- iOS之核心动画(Core Animation)
Core Animation,中文翻译为核心动画,它是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事半功倍.也就是说,使用少量的代码就可以实现非常强大的功能. Core ...
- iOS - Core Animation(核心动画)
Core Animation,中文翻译为核心动画,它是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事半功倍.也就是说,使用少量的代码就可以实现非常强大的功能.Core An ...
- iOS带动画的环形进度条(进度条和数字同步)
本篇写的是实现环形进度条,并带动画效果,要实现这些,仅能通过自己画一个 方法直接看代码 为了方便多次调用,用继承UIView的方式 .m文件 #import <UIKit/UIKit.h> ...
随机推荐
- Learning Docker--chapter 1
CONTENTS: (1) An introduction to Docker (2) Docker on Linux (3) Differentiating between containeriza ...
- itunes一进store就提示已停止工作该怎么解决
改兼容,换盘重装什么的都试过了没用,可以听歌更新软件更改账号,但是就是进不了store,每次都是这个进度就卡死了. 问题事件名称: APPCRASH 应用程序名: iTunes.exe 应用程序版本: ...
- PostgreSQL的时间函数使用整理
PG的时间函数使用整理如下 1.获取系统时间函数 select now(); --2012-05-12 18:51:59.562+08 select current_timestamp; --2012 ...
- 动态修改ActionBar Menu的显示
应用场景: 在主Activity中,采用InstrumentedActivity侧边栏的方式,侧边栏的每一项对应一个Fragment,要实现不同的Fragment动态显示与隐藏ActionBar Me ...
- REDIS主从配置及切换
最近公司项目也用上了.但有个点没有弄很明白. requirepass只是给CLIENT认证用的,还是同时给从REDIS认证用的?(masterauth) 一般的思路是主服务器不开AOF,从服务器打开A ...
- bitmap 内存溢出OOM的解决办法分享
昨天遇到这个问题就是从一个输入流里调用BitmapFactory.decodeStream(this.getContentResolver().openInputStream(uri))得到一个bit ...
- 【转】用户空间使用i2c_dev--不错
原文网址:http://blog.csdn.net/yuanlulu/article/details/6161706 ========================================= ...
- poj1363
堆栈的模拟,给定序列,1,2,3,4,...判断堆栈出栈顺序是否合法 5 //5个数入栈1 2 3 4 5 //出栈顺序5 4 1 2 3 //出栈顺序0 //5个数的结束6 //6个数的入栈6 5 ...
- hdu 3853 LOOPS(概率 dp 期望)
Problem Description Akemi Homura is a Mahou Shoujo (Puella Magi/Magical Girl). Homura wants to help ...
- pyQt事件处理
Qt事件处理01 Qt处理事件的第二种方式:"重新实现QObject::event()函数",通过重新实现event()函数,可以在事件到达特定的事件处理器之前截获并处理他们.这种 ...