OS SWIFT基本画图教程其实这是以前做过的一个例子,方便自己参考的代码!希望对大家也有点参考.首先,建立一个Swift类,继承UIView这个类,然后重写funcdrawRect(rect:CGRect)其次,获取画笔的上下文varcontext:CGContextRef=UIGraphicsG...
分类:
移动开发 时间:
2015-11-08 14:12:08
阅读次数:
613
首先了解一下CGContextRef: An opaque type that represents a Quartz 2D drawing environment. Graphics Context是图形上下文,可以将其理解为一块画布,我们可以在上面进行绘画操作,绘制完成后,将画布放到我们的v...
分类:
其他好文 时间:
2015-11-03 12:38:43
阅读次数:
341
1.Quartz2D在iOS开发中的价值
?自定义view(自定义UI控件)
2.图形上下文
1)图形上下文(Graphics Context):是一个CGContextRef类型的数据
2)图形上下文的作用
Ø保存绘图信息、绘图状态
Ø决定绘制的输出目标(绘制到什么地方去?)
(输出目标可以是PDF文件、Bitmap或者显示器的窗口上)
3)相同的...
分类:
其他好文 时间:
2015-10-27 17:43:46
阅读次数:
271
1.获取当前的画板CGContextRef context = UIGraphicsGetCurrentContext();2.设置画笔的颜色CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);CGContext...
分类:
其他好文 时间:
2015-10-23 18:33:40
阅读次数:
195
0 CGContextRef context = UIGraphicsGetCurrentContext(); 设置上下文1 CGContextMoveToPoint 开始画线2 CGContextAddLineToPoint 画直线4 CGContextAddEllipseInRect 画一椭圆4...
分类:
其他好文 时间:
2015-10-15 18:24:23
阅读次数:
185
CGContextRef context = UIGraphicsGetCurrentContext(); //设置上下文 //画一条线 CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);//线条...
分类:
移动开发 时间:
2015-10-10 12:22:43
阅读次数:
326
#import "MyLayer.h"@implementation MyLayer- (void)drawInContext:(CGContextRef)ctx{ // 设置填充色 CGContextSetRGBFillColor(ctx, 1, 0, 0, 1); // 椭圆 ...
分类:
其他好文 时间:
2015-10-02 19:50:41
阅读次数:
158
做项目让做一个加载动画,一个圈圈在转中间加一个图片,网上有好多demo,这里我也自己写了一个,中间的图片可加可不加。其中主要用到贝塞尔曲线。UIBezierPath是对CGContextRef的进一步封装,不多说直接上代码:#import @interface CircleLoader : UIVi...
分类:
移动开发 时间:
2015-09-15 16:21:41
阅读次数:
194
------------------------------ 旋转 平移 缩放 ---------------------------------- - (void)drawRect:(CGRect)rect { // 获取上下文 CGContextRef ctx = UIGr...
分类:
其他好文 时间:
2015-09-14 00:31:49
阅读次数:
192
//创建图形上下文 UIGraphicsBeginImageContext(CGSizeMake(200, 200)); CGContextRef context = UIGraphicsGetCurrentContext(); UIImage *image = [UIIm...
分类:
其他好文 时间:
2015-09-13 21:35:03
阅读次数:
134