简体   繁体   中英

How to draw variable-width UIBezierPath?

I'm wondering how I should go about drawing a uibezierpath where the stroke width peaks at the center of the arc. Here's an example of what I mean:

曲线

Either I have to go through each point when drawing, and set the stroke width accordingly, or there's an easier way. Can anyone point me in the right direction?

Thanks

您可以只绘制没有笔划的两个外部路径,连接它们,然后填充它们之间的空间。

Another way to try this if you're interested:

I ended up getting this to work by creating a loop to draw a couple hundred line segments, and changing the line width accordingly during the draw loop.

To adjust the line width I used the following function: MAX_WIDTH * sinf(M_PI * (i/NUMBER_OF_SEGMENTS)

Looks great and no performance issues as far as I can tell. Worked out particularly well because I already had a list of the points to use on the curve. For other cases I'm guessing it would be better to use sosborn's method.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM