Core Graphics中的浮雕效果

Div*_*ert 8 iphone core-graphics objective-c quartz-graphics ios4

我再次提出两个相互关联的问题

  1. 我想绘制带有核心图形的浮雕线条.任何人都可以建议我如何给触摸事件上的线条提供内部阴影?
  2. 即使是绘制外部阴影.阴影在两者之间绘制重叠.用黑色以外的颜色绘制的线就像蠕虫..任何人都可以帮助我吗?下面的图片说明了我对问题2的解释:在此输入图像描述 阴影创造不均匀.它们在某些方面变暗

我正在添加我用来绘制线条的代码..

    for (int i=0; i<[currentPath count]; i++) 
    {
        CGPoint mid1 = [[self midPoint:[currentPath objectAtIndex:i+1]  :[currentPath objectAtIndex:i]] CGPointValue]; 
        CGPoint mid2 = [[self midPoint:[currentPath objectAtIndex:i+2] :[currentPath objectAtIndex:i+1]] CGPointValue];
        CGContextMoveToPoint(context, mid1.x, mid1.y);
        CGContextAddQuadCurveToPoint(context, [[currentPath objectAtIndex:i+1] CGPointValue].x, [[currentPath objectAtIndex:i+1] CGPointValue].y, mid2.x, mid2.y); 
        CGContextSetShadow(context, CGSizeMake(-2, -2), 3);

        CGContextSetLineCap(context, kCGLineCapRound);
        CGContextSetStrokeColorWithColor(context,[color CGColor]);              
        CGContextSetLineWidth(context, linewidth);              
        CGContextStrokePath(context);
        i+=2;
    }
Run Code Online (Sandbox Code Playgroud)

Div*_*ert 4

我找到了我的解决方案..问题非常愚蠢...我在每次迭代中都添加了导致问题的路径..现在我什至可以使用小于1的alpha进行绘制..

CGContextStrokePath(context);
Run Code Online (Sandbox Code Playgroud)

这条线超出了 for 循环..现在一切正常:)