UIGraphicsGetCurrentContext() 获得上下文
CGContextSetRGBStrokeColor 画线颜色
CGContextSetStrokeColorWithColor
CGContextSetRGBFillColor 填充颜色
CGContextSetLineWidth 画线宽度
CGContextMoveToPoint 移动到某点
CGContextAddLineToPoint 画线到某点
CGContextAddRect 在所给范围内画方形
CGContextStrokeRect = CGContextAddRect + CGContextStrokePath
CGContextStrokeRectWithWidth = CGContextStrokeRect + CGContextSetLineWidth
CGContextFillRect 填充一个方形
CGContextAddEllipseInRect 在所给范围内画椭圆(圆形)
CGContextStrokeEllipseInRect = CGContextAddEllipseInRect + CGContextStrokePath
CGContextFillEllipseInRect = CGContextAddEllipseInRect + CGContextFillPath
CGContextStrokePath 开始画线
CGContextFillPath 填充一个图形
CGContextAddLines 画多条线
This function is equivalent to
Equivalent to MoveToPoint(points[0]); for(i=1; i<count; ++i) AddLineToPoint(points[i]);
CGContextAddRects 画多个方形
CGContextStrokeLineSegments
This function is equivalent to
CGContextBeginPath(context)
for (k = 0; k < count; k += 2) {
CGContextMoveToPoint(context, s[k].x, s[k].y);
CGContextAddLineToPoint(context, s[k+1].x, s[k+1].y);
}
CGContextStrokePath(context);
CGContextSaveGState 保存当前画图部分
CGContextClosePath 闭合当前路径
CGContextSetLineCap 边角特征
enum CGLineCap {
kCGLineCapButt,
kCGLineCapRound,
kCGLineCapSquare
};
typedef enum CGLineCap CGLineCap;
CGContextSetLineJoin 拐角特征
enum CGLineJoin {
kCGLineJoinMiter,
kCGLineJoinRound,
kCGLineJoinBevel
};
typedef enum CGLineJoin CGLineJoin;
CGContextSetLineDash 破折号特征
CGContextDrawPath 根据所给模式画图
enum CGPathDrawingMode {
kCGPathFill,
kCGPathEOFill,
kCGPathStroke,
kCGPathFillStroke,
kCGPathEOFillStroke
};
typedef enum CGPathDrawingMode CGPathDrawingMode;
CGContextAddArc 画一个arc曲线
`(x, y)' is the center of the arc; `radius' is its
radius; `startAngle' is the angle to the first endpoint of the arc;
`endAngle' is the angle to the second endpoint of the arc; and
`clockwise' is 1 if the arc is to be drawn clockwise, 0 otherwise.
`startAngle' and `endAngle' are measured in radians
CGContextAddArcToPoint 画一个曲线
/* Add an arc of a circle to the context's path, possibly preceded by a
straight line segment. `radius' is the radius of the arc. The arc is
tangent to the line from the current point to `(x1, y1)', and the line
from `(x1, y1)' to `(x2, y2)'. */
CGContextAddCurveToPoint 画bezier曲线(根据两条线)
CGContextAddQuadCurveToPoint 画bezier曲线(根据一线一点)
CGContextDrawTiledImage 以平铺的模式画图片
CGContextTranslateCTM 根据所给参数进行移动
CGContextScaleCTM 根据所给参数进行缩放
{
CGPDFDocumentGetPage 根据所给的页面参数抓取pdf文件
}
CGContextDrawPDFPage 画pdf
CGContextSelectFont 选择所画文字的字体
CGContextSetTextMatrix 调整画字(画字时文字向下)
CGContextSetTextDrawingMode 设置画字的模式
enum CGTextDrawingMode {
kCGTextFill,
kCGTextStroke,
kCGTextFillStroke,
kCGTextInvisible,
kCGTextFillClip,
kCGTextStrokeClip,
kCGTextFillStrokeClip,
kCGTextClip
};
CGContextShowTextAtPoint 根据所给位置显示文字
CGContextGetClipBoundingBox 获得context的cgrect
{
CGRectInset 根据所给的cgrect和边框值确定cgrect
}
CGContextClipToRect 使context根据所给的cgrect确定大小
CGContextDrawLinearGradient 画渐变效果(直线)
CGContextDrawRadialGradient 画渐变效果(圆形)
eg:
/*
CGColorSpaceRef rgb = CGColorSpaceCreateDeviceRGB();
CGFloat colors[] =
{
204.0 / 255.0, 224.0 / 255.0, 244.0 / 255.0, 1.00,
29.0 / 255.0, 156.0 / 255.0, 215.0 / 255.0, 1.00,
0.0 / 255.0, 50.0 / 255.0, 126.0 / 255.0, 1.00,
};
gradient = CGGradientCreateWithColorComponents(rgb, colors, NULL, sizeof(colors)/(sizeof(colors[0])*4));
CGColorSpaceRelease(rgb);
CGContextDrawLinearGradient(context, gradient, start, end, options);
*/