
我正在绘制使用以下功能:
- (voID)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{ UItouch *touch = [touches anyObject]; CGPoint currentPoint = [touch locationInVIEw:self.canvasVIEw]; UIGraphicsBeginImageContext(self.canvasVIEw.frame.size); [canvasVIEw.image drawInRect:self.canvasVIEw.frame]; CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextSetShouldAntialias(ctx,YES); CGContextSetlineCap(ctx,kCGlineCapRound); CGContextSetlinewidth(ctx,5.0); CGContextSetRGBstrokecolor(ctx,1.0,0.0,1.0); CGContextBeginPath(ctx); CGContextMovetoPoint(ctx,lastPoint.x,lastPoint.y); CGContextAddlinetoPoint(ctx,currentPoint.x,currentPoint.y); CGContextstrokePath(ctx); canvasVIEw.image = UIGraphicsGetimageFromCurrentimageContext(); UIGraphicsEndImageContext(); lastPoint = currentPoint; // some code omitted from this example}@H_419_5@ 我发现的建议是use the scaleFactor property,或CGContextSetShouldAntialias() function,但这两个都没有帮助到目前为止. (虽然我可能不正确地使用它们)
任何帮助将不胜感激.
解决方法 您需要用UIGraphicsBeginImageContext替换 if (UIGraphicsBeginImageContextWithOptions != NulL) { UIGraphicsBeginImageContextWithOptions(size,NO,0.0);} else { UIGraphicsBeginImageContext(size);}@H_419_5@ UIGraphicsBeginImageContextWithOptions是在4.x软件中引入的.如果要在3.x设备上运行此代码,则需要使用弱链接UIKit框架.如果您的部署目标是4.x或更高版本,您可以使用UIGraphicsBeginImageContextWithOptions,而无需任何额外的检查.
总结 以上是内存溢出为你收集整理的ios – 使用CoreGraphics绘制视网膜显示 – 图像像素化全部内容,希望文章能够帮你解决ios – 使用CoreGraphics绘制视网膜显示 – 图像像素化所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)