绘制透明时删除虚线

时间:2012-06-15 08:36:39

标签: ios core-graphics quartz-2d

我只是在开发一个绘图应用程序。我需要绘制一条透明线,每当我绘制时,我都会出现在线上的点。

我该如何纠正这个问题?如何从线上删除点?

我的代码在这里

- (UIImage *)drawSmoothLine  // stright line correct
{
    CGPoint mid1    = midPoint(previousPoint1, previousPoint2); 
    CGPoint mid2    = midPoint(currentPoint, previousPoint1);

    CGSize screenSize = self.frame.size;
    UIGraphicsBeginImageContext(screenSize);

    CGContextRef context = UIGraphicsGetCurrentContext(); 

    [self.layer drawInContext:context];


    CGContextMoveToPoint(context, mid1.x, mid1.y);

    CGContextAddQuadCurveToPoint(context, previousPoint1.x, previousPoint1.y, mid2.x, mid2.y); 

    CGContextSetLineCap(context, kCGLineCapRound);

    CGContextSetStrokeColorWithColor(context, drawColor.CGColor);


    CGContextSetBlendMode(context, kCGBlendModeColorBurn);
    CGContextSetLineWidth(context, lineWidth);

    CGContextStrokePath(context);

    UIImage *ret = UIGraphicsGetImageFromCurrentImageContext();

    UIGraphicsEndImageContext();

    return ret;
}

Ipad screen shot of bug http://dc471.4shared.com/img/3_9Uo8qT/s3/Screen_shot_2012-06-15_at_1564.png

1 个答案:

答案 0 :(得分:0)

尝试使用UIBezierPath 请查看this link以供参考,并根据您的需要进行修改。 希望这会对你有所帮助。