我使用uigraphics cgcontext在触摸上绘制线条...但我的线条不平滑我的意思是边缘不光滑所以任何人都可以建议我如何画出流畅的线条.这里是我用来画线的代码:
/* touchesBegan */
UITouch *touch = [touches anyObject];
lastPoint = [touch locationInView:imagevw];
/* touchesMoved */
CGFloat width = [mySlider value];
UIGraphicsBeginImageContext(imagevw.frame.size);
[imagevw.image drawInRect:CGRectMake(0, 0, imagevw.frame.size.width,imagevw.frame.size.height)];
CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
CGContextSetLineWidth(UIGraphicsGetCurrentContext(), width);
UITouch *touch = [touches anyObject];
mouseSwiped = YES;
CGPoint currentPoint = [touch locationInView:imagevw];
CGContextBeginPath(UIGraphicsGetCurrentContext());
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
CGContextStrokePath(UIGraphicsGetCurrentContext());
imagevw.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
lastPoint = currentPoint;
/* touchesEnded */
/* same here */
CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);`
Run Code Online (Sandbox Code Playgroud)
这是我的代码,我可以画线自由,但它不是那么平滑显示像素我的意思是边缘不平滑
任何人都可以帮我找出如何在日冕中获得矩形的颜色?那个矩形我已经填充了颜色,所以现在我想在触摸矩形时获得那种颜色.