1.画三角形- (void)drawRect:(CGRect)rect { // 获取上下文 CGContextRef ctx = UIGraphicsGetCurrentContext(); // 确定三个点 CGContextMoveToPoint(ctx, 30...
分类:
其他好文 时间:
2015-12-07 20:47:52
阅读次数:
212
UIView的drawRect方法CoreGraphics绘图综述:描述系统会调用UIView的drawRect方法,所以coreGraphics的所有实现代码放在该函数内,setNeedsDisplay是更新整个视图,setNeedsDisplayInRect是更新视图的一个区域。CGContex...
分类:
移动开发 时间:
2015-12-04 12:18:47
阅读次数:
203
下面代码实现画圆、画弧、画扇形//画圆- (void)drawCircle{ //获取上下文 CGContextRef context = UIGraphicsGetCurrentContext(); //画圆 CGContextAddEllipseInRect(context, CGRe...
分类:
其他好文 时间:
2015-12-02 00:54:53
阅读次数:
129
一、自定义层的方法11.创建一个 CALayer 的子类2.在. m 文件中覆盖 drawInContext:方法,在里面绘图- (void)drawInContext:(CGContextRef)ctx { 5 // 设置为蓝色 6 CGContextSetRGBFillColor...
- (void)drawRect:(CGRect)rect { CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSaveGState(ctx); CGContextMoveToPoint(ctx, 0, 0); CGConte.....
分类:
其他好文 时间:
2015-11-23 20:34:58
阅读次数:
165
1.三角形- (void)drawRect:(CGRect)rect { // Drawing code// 1.获得图形上下文 CGContextRef ctx = UIGraphicsGetCurrentContext();// 2.拼接图形 CGContextMoveToPoint(ctx, ...
分类:
其他好文 时间:
2015-11-23 18:31:42
阅读次数:
150
这三种东西:CGContextRef,CGPath和UIBezierPath。本质上都是一样的,都是使用Quartz来绘画。只不过把绘图操作暴露在不同的API层面上,在具体实现上,当然也会有一些细小的差别。我们将主要使用这3个类型,绘制出同一张图片,如下,一个笑脸:首先使用Quartz的CGPath...
分类:
移动开发 时间:
2015-11-20 19:14:56
阅读次数:
198
Paths中的几个重要元素Pointsvoid CGContextMoveToPoint ( CGContextRef c, CGFloat x, CGFloat y);指定一个点成为current pointQuartz会跟踪current point一般执行完一个相关函数后,current po...
分类:
其他好文 时间:
2015-11-19 18:30:45
阅读次数:
287
- (void)drawRect:(CGRect)rect{ // 获取context CGContextRef context = UIGraphicsGetCurrentContext(); // 画直线 CGContextMoveToPoint(context, 50, 100); ...
分类:
其他好文 时间:
2015-11-16 19:30:44
阅读次数:
147
首先了解一下CGContextRef:An opaque type that represents a Quartz 2D drawing environment.Graphics Context是图形上下文,可以将其理解为一块画布,我们可以在上面进行绘画操作,绘制完成后,将画布放到我们的view中...
分类:
移动开发 时间:
2015-11-08 14:19:35
阅读次数:
369