加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

xcode iphone触摸虚线画

发布时间:2020-12-14 17:48:47 所属栏目:百科 来源:网络整理
导读:我每个身体都是法国人,所以请原谅我的英语.我的问题是我想用手指在 iphone上绘制一个像———–这样的虚线图画,不是一条线而是一个平局.我有: CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGLineCapRound); //kCGLineCapSquare,kCGLineCapButt,kCG
我每个身体都是法国人,所以请原谅我的英语.我的问题是我想用手指在 iphone上绘制一个像———–这样的虚线图画,不是一条线而是一个平局.我有:

CGContextSetLineCap(UIGraphicsGetCurrentContext(),kCGLineCapRound); //kCGLineCapSquare,kCGLineCapButt,kCGLineCapRound
CGContextSetLineWidth(UIGraphicsGetCurrentContext(),10.0); // for size
CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(),0.0,1.0,1.0); //values for R,G,B,and Alpha
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(),lastPoint.x,lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(),currentPoint.x,currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

请点击“点”代码是什么.

解决方法

CGContextSetLineDash

http://developer.apple.com/library/mac/#documentation/GraphicsImaging/Reference/CGContext/Reference/reference.html%23//apple_ref/c/func/CGContextSetLineDash

例:

CGFloat dashes[] = { 1,1 };
CGContextSetLineDash( context,dashes,2 );

或者只需在Xcode中打开QuartzDemo示例并查看QuartzLines.m文件(QuartzDashView类).

你应该阅读文档(参见已经提到过的链接).

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读