
//获取用语描画的全局对象 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))总结
以上是内存溢出为你收集整理的Swift 基本图形全部内容,希望文章能够帮你解决Swift 基本图形所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)