var content=UIGraphicsGetCurrentContext()//设置上下文
//弧心,位置,半径,起始角度,弧度,顺时针还是逆时针0顺时针1腻时针
//绘制圆形填充
CGContextAddArc(content, 35, 40, 25, 0, 3.14*2, 0)
CGContextSetRGBFillColor(content, 1, 0, 0, 1)
CGContextFillPath(content)
//绘制线条
CGContextAddArc(content, 35, 40, 25, 0, 3.14*2, 0)
CGContextSetLineWidth(content, 5)
//画一个椭圆或者园当高宽等于的时候就是园,反之则是椭圆
CGContextAddEllipseInRect(content, CGRect(x: 40, y: 30, width: 50, height: 25))
CGContextStrokePath(content)
CGContextRef context = UIGraphicsGetCurrentContext(); //设置上下文
CGContextMoveToPoint //开始画线
CGContextAddLineToPoint //画直线
CGContextAddEllipseInRect //画一椭圆
CGContextSetLineCap //设置线条终点形状
CGContextSetLineDash 画虚线
CGContextAddRect 画一方框
CGContextStrokeRect 指定矩形
CGContextStrokeRectWithWidth 指定矩形线宽度
CGContextStrokeLineSegments 一些直线
CGContextAddArc 画已曲线 前俩店为中心 中间俩店为起始弧度 最后一数据为0则顺时针画 1则逆时针
CGContextAddArcToPoint(context,0,0, 2
CGContext的基本认识(绘图)
最新推荐文章于 2019-07-29 15:02:00 发布
本文详细介绍了在iOS开发中Core Graphics框架下的CGContext绘图操作,包括设置上下文、绘制圆形、线条、椭圆、阴影、颜色填充等,并提供了相关代码示例,帮助开发者掌握CGContext的基本用法。
摘要由CSDN通过智能技术生成