1 绘画layer
1.1、实例化layer
1.2、设置layer的位置 bounds
1.3、设置圆心 position
1.4、边框宽度 borderWidth
边框颜色 borderColor
背景色 backgroundColor
1.5、设置切脚 corneRadius
1.6、阴影部分方向 shadowOpacity
阴影部分 shadowRadius
2.鼠标点击移动
2.1、实例化touch UITouch *touch=[touches anyObject]
2.2、 获取鼠标点击当前位置
CGPoint point=[touch locationInView:self.view]
2.3、第三个视图 UIView *view=[self.view subviews][2]
2.4、中心点 [UIView animateWithDuration:1 animations:^{view.center=point;}]
3.鼠标点击结束
3.1、实例化touch
3.2、获取当前位置
3.3、第四个视图
3.4、视图缩放大小
#define HEIGHT 50
int width = layer.bounds.size.width;
if (width == HEIGHT) {
width = HEIGHT*4;
}else
{
width = HEIGHT;
}
3.5、点击之后的位置 bounds
3.6、切脚 cornerRadius
4、继承于CALayer , 用layer绘图
4.1、创建一个继承于UIView的类,引入CALayer 的类,实例化
4.2、 在ViewController引入继承于UIView的类,实例化
4.3、重写一个方法drawInContext(不需要获取上下文)
4.4、设置背景色 CGContextSetRGBFillColor
4.5、设置线宽 CGContextSetLineWidth
设置线的颜色 CGContextSetRGBStrokeColor
本文详细介绍如何在iOS中使用CALayer进行绘图,并实现触摸交互功能,包括实例化图层、设置图层属性、响应触摸事件等步骤。
249

被折叠的 条评论
为什么被折叠?



