标签:color io os ar for sp art on ad
Quartz2D
图形上下文 CGContextRef
绘制输出目标
PDF Bitmap 屏幕
window
printer
layer
-(void)drawRect:(GCRect)
UIGraphicsGetCurrentContext()
画线段
CGContextMoveToPoint(ctx,10,10)
CGContextAddLineToPoint(ctx,100,100)
CGContextAddLineToPoint(ctx,10,20)
CGContextClosePath(ctx)//封闭图形 关闭路径 画三角形
CGContextStrokePath(ctx)//空心
CGContextFillPath(ctx)//实心
CGContextAddRect(ctx,CGRectMake(10,10,100,100))画矩形
CGContextSetLineWidth(ctx,10)//状态设置线宽在渲染画布之前设定
CGContextSetRGBStrokeColor(ctx,r,g,b,a) //rgba取值0-1
//线段头尾样式
CGContextSetLineCap(ctx,kCGLineCapRound)
//线段转折点样式
GCContextSetLineJoin(ctx,kCGLineJoinRound)
[[UIColor whiteColor] set]//空心实心通用设置颜色
//画圆
CGContextAddEllipseInRect(ctx,CGRect)//圆
//画圆弧
CGContextAddArc(ctx,x,y,r,angle,endangle,clockwise(0,1,伸展方向,顺时针 逆时针))
//画文字
CGContextShowTextAtPoint()//c语言的 复杂
[str drawArPoint:Point withAtttributes]//OC语法不需要上下文不需要 渲染,传递 位置与文字字典
drawInRect 限制在矩形框中
//画图片
image drawInRect//拉伸 drawArPoint
drawAsPaternInRect//平铺
//曲线
CGContextAddQuadCurveTopint(ctx,cX,cY,eX,eY)//贝塞尔曲线cX cY控制点
图形上下文栈
CGContextSavaState
图片裁剪
UIGraphicsBeginImagecontextWithOption(size,NO,0.0)
CGContextClip()
image drawInRect:]
UIGraphicsGetImageFromCurrentImgeContext();
data = UIImagePNGRepresentation(image)
NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,Yes ) StringByAppend(@“ddd.png”)
截屏
UIGraphicsBeginImageContextWithOptions(view.frame.size,NO,0.0);
self.view.layer renderInContecct:UIGraphicsGetCurrentImageContext();
UIGraphicsEndImageContext
标签:color io os ar for sp art on ad
原文地址:http://my.oschina.net/renyunxiang/blog/330107