iOS Core Animation学习总结(2)--实现自定义图层
一. 创建图层继承于CALayer,并在子类实现drawInContext方法
@interface CTLayer : CALayer @end @implementation CTLayer
-(void)drawInContext:(CGContextRef)ctx{
//画一个圆
CGContextSetRGBFillColor(ctx, , , , );
CGContextAddEllipseInRect(ctx, CGRectMake(, , , ));
CGContextFillPath(ctx);
}
@end
在viewcontroller加载视图时,
CTLayer *layer = [CTLayer layer];
layer.bounds = CGRectMake(, , , );
layer.anchorPoint = CGPointMake(,);
[layer setNeedsDisplay];//显示图层
[self.view.layer addSublayer:layer];
二. 使用代理方式创建
CTLayer *layer = [CTLayer layer];
layer.bounds = CGRectMake(, , , );
layer.anchorPoint = CGPointMake(,);
layer.delegate = self; //指定代理,该代理可为任意类型
[layer setNeedsDisplay];//显示layer
[self.view.layer addSublayer:layer];
实现代理方法
#pragma mark 代理方法
-(void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx{
CGContextSetRGBFillColor(ctx, , , , );
CGContextAddEllipseInRect(ctx, CGRectMake(, , , ));
CGContextFillPath(ctx);
}
iOS Core Animation学习总结(2)--实现自定义图层的更多相关文章
- iOS Core Animation学习总结(1)--CALayer常用属性
图层是core animation的基础, UIView之所以能显示在屏幕上,靠的是其内部的这个图层,即每个UIView 都有 CALayer,可通过UIView.layer或者[UIView lay ...
- iOS Core Animation学习总结(3)--动画的基本类型
一. CABasicAnimation (基础动画) 移位: CABasicAnimation *animation = [CABasicAnimation animation]; //keyPath ...
- 转 iOS Core Animation 动画 入门学习(一)基础
iOS Core Animation 动画 入门学习(一)基础 reference:https://developer.apple.com/library/ios/documentation/Coco ...
- iOS Core Animation 简明系列教程
iOS Core Animation 简明系列教程 看到无数的CA教程,都非常的难懂,各种事务各种图层关系看的人头大.自己就想用通俗的语言翻译给大家听,尽可能准确表达,如果哪里有问题,请您指出我会尽 ...
- iOS - Core Animation 核心动画
1.UIView 动画 具体讲解见 iOS - UIView 动画 2.UIImageView 动画 具体讲解见 iOS - UIImageView 动画 3.CADisplayLink 定时器 具体 ...
- Core Animation学习总结
文件夹: The Layer Beneath The Layer Tree(图层树) The Backing Image(寄宿层) Layer Geometry(图层几何学) Visual Effec ...
- iOS Core Animation 动画 入门学习(一)基础
reference:https://developer.apple.com/library/ios/documentation/Cocoa/Conceptual/CoreAnimation_guide ...
- IOS Core Animation Advanced Techniques的学习笔记(五)
第六章:Specialized Layers 类别 用途 CAEmitterLayer 用于实现基于Core Animation粒子发射系统.发射器层对象控制粒子的生成和起源 CAGradient ...
- IOS Core Animation Advanced Techniques的学习笔记(四)
第五章:Transforms Affine Transforms CGAffineTransform是二维的 Creating a CGAffineTransform 主要有三种变 ...
随机推荐
- other
1.http://handlebarsjs.com/ 2.grunt
- Delphi- 操作EXCEL
因工作需要,需要到操作EXCEL,先了解一下怎么读取EXCEL这个,做了一个DEMO,备注在这里 一.读取EXCEL unit Unit1; interface uses Windows, Messa ...
- Java的面向对象思想
多态性: 一种方法有多种实现,采用哪一种实现由Java虚拟机在运行时动态决定,这种能力成为动态绑定(dynamic binding),也称为多态性(polymorphism)(源于一个希腊单词,意为“ ...
- iOS7 人机界面设计指南
iOS7 人机界面设计指南 苹果在WWDC 2013大会上发布了iOS 7,新系统一改5年来的拟物路线,在乔纳森•艾维的主导下,加入了更多的“扁平化”和“极简”现代设计元素. iOS7系统界面 ...
- NSTimer运行机制和线程问题
A.首先要理解NSTimer运行机制和Runloop之间的关系: 1.IOS的Run Loops机制 Run Loops是线程的基础部份,任何线程,包括主结程,都包含了一个run loop对象,Coc ...
- 安装Intel HAXM为Android 模拟器加速,30秒内启动完成
要求 必备知识 windows 7 基本操作. 运行环境 windows 7(64位); Android Studio 1.1.0;JDK 1.7.0_75(64位);android-sdk_r24 ...
- Process学习
主要系统总结下我对进程的认识,以前理解得不够全面不够深入.本文肯定还不够好,当有新的认识新的理解后还会随时来更新.读完本文,下面几个问题便可理解清楚. 1.进程是什么? 2.为什么要有进程这个概念? ...
- C#-动态生成40个按钮,大小(20,20),要求每行6个放置
应该为for (int i=0;i<基本数据DataSet3.Tables [0].Rows .Count ;i++) { int ...
- 第二周:01 ICP迭代交互
本周主要任务01:利用PCL库函数,ICP融合两个角度的点云 任务时间:2014年9月8日-2014年9月14日 任务完成情况:可以使用键盘交互,显示每次ICP迭代结果 任务涉及基本方法: 1.PCL ...
- chrome浏览器更新到chrome 29.0.1547.76 m,多出一些蛋疼的功能来。
更新到chrome 29.0.1547.76 m 的时候,莫名其妙多出一些蛋疼的功能来. 1.alert之类的弹出对话框样式变了,并且位置不是居中的,跑到了最上面去了,如下图. 要把这对话框改回原始状 ...