1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
voidMyDrawColoredPattern(void*info,
CGContextRef context){
CGColorRef dotColor=[UIColor
colorWithHue:0 saturation:0
brightness:0.07 alpha:1.0].CGColor;
CGColorRef shadowColor=[UIColor
colorWithRed:1 green:1
blue:1 alpha:0.1].CGColor;
CGContextSetFillColorWithColor(context,
dotColor);
CGContextSetShadowWithColor(context,
CGSizeMake(0, 1),
1, shadowColor);
CGContextAddArc(context,
3, 3, 4, 0, radians(360),
0);
CGContextFillPath(context);
CGContextAddArc(context,
16, 16, 4, 0, radians(360),
0);
CGContextFillPath(context);
}
-(void)drawLayer:(CALayer*)layer
inContext:(CGContextRef)context{
CGColorRef bgColor=[UIColor
colorWithHue:0.6 saturation:1.0
brightness:1.0 alpha:1.0].CGColor;
CGContextSetFillColorWithColor(context,
bgColor);
CGContextFillRect(context,
layer.bounds);
staticconst CGPatternCallbacks callbacks={0,&MyDrawColoredPattern,NULL};
CGContextSaveGState(context);
CGColorSpaceRef patternSpace=CGColorSpaceCreatePattern(NULL);
CGContextSetFillColorSpace(context,
patternSpace);
CGColorSpaceRelease(patternSpace);
CGPatternRef pattern=CGPatternCreate(NULL,
layer.bounds,
CGAffineTransformIdentity,
24,
24,
kCGPatternTilingConstantSpacing, true, &callbacks);
CGFloat alpha=1.0;
CGContextSetFillPattern(context,
pattern,&alpha);
CGPatternRelease(pattern);
CGContextFillRect(context,
layer.bounds);
CGContextRestoreGState(context); }
|
相关推荐
CALayer基本使用,CALayer基本使用,CALayer基本使用,CALayer基本使用
CALayer 图层处理
这是我自己写的一个关于CALayer的基本使用的代码,需要学习的朋友可以下载看看。以后会陆续上传一些CALayer的高级使用,主要是核心动画方面的内容。
这是我在学习ios的过程中写的一个demo,介绍了CALayer的简单使用。
图层CALayer的一些知识:自定义图层,图层的一些动画
CALayer的子类.zip
通过自定义CALayer,实现星空模拟效果(当然效果一般般)。代码很简单,都在CMLayer类中,仅为大家自定义CALayer并添加相关动画提供一份参考demo。
简单方便的间接实现CALayer的"AutoLayout
一、简单介绍 在iOS中,你能看得见摸得着的东西基本上都是UIView,比如一个按钮、一个文本标签、一个文本输入框、一个图标等等,这些都是UIView。 其实UIView之所以能显示在屏幕上,完全是因为它内部的一个图层,在...
用代码实现三维立体图形
iOS CALayer 思维导图,超级棒棒哒 iOS CALayer 思维导图,超级棒棒哒
传入百分比参数,实现进度条变化,用于下载网络资源时,下载量占总量的多少
iOS CALayer动画实现
利用 CALayer 可以实现复杂的动画效果,同时 CALayer 在运动过程中,需要点击 CALayer,同时能够监控到点击的对象
NULL 博文链接:https://hulefei29.iteye.com/blog/1155377
CALayer指南了解CALayer的财产。
CAlayer层的隐式动画属性
CALayer简介 1. CALayer是核心动画的基础,通过设置CALayer属性可以做圆角,边框,阴影等效果. 2. 每个UIView内部都有一个CALayer类型的属性layer. 3. 在实现核心动画时,本质上是把CALayer中的内容 转换成位图,...
Core Animation基础介绍、简单使用CALayer以及多种动画效果 详细讲解了iOS的动画的原理与应用非常值得深入学习