UI(四十)绘图

作者: 社会主义顶梁鹿 | 来源:发表于2018-07-30 18:07 被阅读0次

绘图-> Quartz 2D -

 #pragma mark----------

 1、画线

  *步骤

 (1)CGContextRef 上下文(相当于画板)

 (2)画图的内容->设置画图的内容

 (3)把内容添加到上下文

 (4)把内容画到上下文(画板)上

 #pragma mark----------

 2、常用方法介绍

 (1)CGContextRef 上下文

 (2)路径

 《1》UIBezierPath 贝塞尔路径-通过点绘制

 《2》CGMutablePathRef 通过点绘制路径

 《3》注意:必须设置起始点 CGContextMoveToPoint(...)

 (3)画形状

 《1》矩形 CGContextAddRect(, );

 《2》曲线 CGContextAddCurveToPoint(, )

 《3》圆形 CGContextAddEllipseInRect(, )

 (3.1)CGContextSetLineWidth 设置笔画宽度

 (3.2)set 设置笔画颜色及其区域范围颜色

 (3.3)setFill 设置画线区域范围填充颜色

 (3.4)setStroke 设置笔画的颜色

 (3.5)CGPathDrawingMode 设置画笔填充样式

 《1》kCGPathFill 只填充

 《2》kCGPathStroke 画笔颜色

 《3》kCGPathFillStroke 既填充又有画笔颜色

 (4)截图

 《1》UIGraphicsBeginImageContext 开始获得图片上下文

 《2》UIGraphicsBeginImageContextWithOptions 开始截图

 《3》UIGraphicsGetImageFromCurrentImageContext()获得当前图片的上下文

 《4》UIGraphicsEndImageContext() 关闭图片上下文

 (5)CGContextStrokePath 把路径绘制到上下文的方法

 (6)直接把路径绘制到界面 stroke

相关文章

网友评论

    本文标题:UI(四十)绘图

    本文链接:https://www.haomeiwen.com/subject/odtqvftx.html