iphone – CGContextAddLineToPoint:没有当前点

iphone – CGContextAddLineToPoint:没有当前点,第1张

概述我正在开发一个模式锁定应用程序(如 Android锁定). 我想在点之间画线来打开锁,但是当我画画时,它会返回一个错误: <错误>:CGContextAddLineToPoint:没有当前点 它在iOS 5.0和之前的工作正常但它在5.1中显示错误. 这是我的代码: - (void)drawRect:(CGRect)rect{ NSLog(@"drawrect...%@",NSStringFr 我正在开发一个模式锁定应用程序(如 Android锁定).

我想在点之间画线来打开锁,但是当我画画时,它会返回一个错误:

<错误>:CGContextAddlinetoPoint:没有当前点

它在iOS 5.0和之前的工作正常但它在5.1中显示错误.

这是我的代码:

- (voID)drawRect:(CGRect)rect{ NSLog(@"drawrect...%@",NsstringFromCGRect(rect)); if (!self._trackPointValue) return;CGContextRef context = UIGraphicsGetCurrentContext();CGContextSetlinewidth(context,10.0);CGcolorSpaceRef colorspace = CGcolorSpaceCreateDeviceRGB();CGfloat components[] = {0.5,1.0,0.5,0.8};CGcolorRef color = CGcolorCreate(colorspace,components);CGContextSetstrokecolorWithcolor(context,color);CGPoint from;UIVIEw *lastDot;for (UIVIEw *dotVIEw in self._dotVIEws) {  //_dotVIEws array of points from = dotVIEw.center;       if (!lastDot) {  CGContextMovetoPoint(context,from.x,from.y);  } else {    NSLog(@"from : %@",NsstringFromCGPoint(from));   CGContextAddlinetoPoint(context,from.y); } lastDot = dotVIEw;} CGPoint pt = [self._trackPointValue CGPointValue];  //_trackPointValue is current point CGContextAddlinetoPoint(context,pt.x,pt.y); CGContextstrokePath(context); CGcolorSpaceRelease(colorspace); CGcolorRelease(color); self._trackPointValue = nil;//_trackPointValue is current point }
解决方法 要获得当前点,您必须确保在CGContextAddlinetoPoint开始运行之前至少调用一次CGContextMovetoPoint. 总结

以上是内存溢出为你收集整理的iphone – CGContextAddLineToPoint:没有当前点全部内容,希望文章能够帮你解决iphone – CGContextAddLineToPoint:没有当前点所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1061069.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-25
下一篇 2022-05-25

发表评论

登录后才能评论

评论列表(0条)

保存