//获取用语描画的全局对象
var context = UIGraphicsGetCurrentContext()
//设定颜色
CGContextSetRGBstrokeColor(context,1,1)
//线宽度
CGContextSetlinewidth(context,10)
//移动到 位置
CGContextMovetoPoint(context,100,100)
//开始线性移动
CGContextAddLinetoPoint(context,200)
CGContextAddLinetoPoint(context,200,200)
CGContextMovetoPoint(context,300)
CGContextAddLinetoPoint(context,400)
//描画轨迹
CGContextstrokePath(context)
矩形描画方式
var context = UIGraphicsGetCurrentContext()
//追加矩形
CGContextAddRect(context,CGRect(x: 100,y: 100,width: 100,height: 100))
//设定颜色
CGContextSetRGBFillColor(context,1)
//填充形状
CGContextFillPath(context)
//描画边框 和画直线不同处在于 画线最后调用的是: CGContextstrokePath
CGContextSetlinewidth(context,5)
CGContextSetRGBstrokeColor(context,1)
CGContextstrokeRect(context,height: 100))