基本绘图
quartz2d基本原理
Quartz是iPhone OS的窗口服务器和描画技术的一般叫法
CoreGraphics框架是Quartz的核心,也是内容描画的基本接口。
每次成功绘图,都是在这个之前的基础上层叠绘上去的,不能再绘图改掉那一块
无法撤销,永远都是增量式改进
需重新绘制view时,不能直接调用drawRect方法
而是调用
//重新绘制整个view
-(void)setNeedsDisplay
//在view的某个区域内重新绘制
- (void)setNeedsDisplayInRect:(CGRect)rect
//获取上下文
CGContextRef context = UIGraphicsGetCurrentContext();
//参数一:上下文,参数二:R 参数三:G 参数四:B 参数五:透明度;
CGContextSetRGBStrokeColor
//绘图宽度
CGContextSetLineWidth
//绘图形状-----圆形
CGContextAddEllipseInRect
(conref,CGRectMake(0,50,320,320));
//绘图形状------矩形
CGRect rect[4];
rect[0] = CGRectMake(60,130,50,25);
rect[1[ = CGRectMak(185,130,50,25];
CGContextAddRects(conref,rete,2];
//绘图形状-----椭圆
//参数a:上下文 参数:b:椭圆的坐标
CGContextAddEllipseInRect
//绘图形状-----贝塞尔曲线
//开始点
CGContextMoveToPoint(contest ,160,220);
//参数a:上下文 参数b 参数c :焦点 ;参数d 参数e:终点
CGContextAddQuadCurveToPoint
绘图形状------直线
//开始点
CGContextMoveToPoint(contest ,160,220);
//结束点
CGContextAddLineToPoint