How do I draw lines with alpha < 1 in quartz 2d

前端 未结 4 1414
执笔经年
执笔经年 2020-12-20 01:12

No doubt this might be a duplicate question but I am not able to get proper solution from any post here. So I am posting this as new post with a hope that I get some solutio

4条回答
  •  春和景丽
    2020-12-20 01:40

    It looks like you're drawing a circle at every point of a series of touch events. Instead, you can build a Path with CoreGraphics/Quartz2D, set the line width to be whatever thickness, and then stroke that path as needed to keep the UI looking nice. I've not done this in a while, but I think most of what you need will be in CoreGraphics/CGContext.h and ~/CGPath.h, etc. See my answer to another CoreGraphics problem here.

    The one unknown in my mind right now is whether you can stroke a CGMutablePathRef to a context before you 'close' it using CGPathCloseSubpath(). You'll have to experiment. At any rate, as you receive mouse events, you will build a path up with the new points and render it a little at a time. Let me know if you need clarification.

    P.S. as for opacity, you will set it when you create the CGColorRef for your context... many of the calls in CoreGraphics/CGColor.h have an alpha parameter.

提交回复
热议问题