UIBezierPath Gives Sharp Edges
When I'm using a UIBezierPath to draw where the user is touching if the user moves to fast sometimes I get really hard points like the tip of a triangle. Any clue what might be causing th开发者_如何学Cis? Or how I can fix it?
I am capturing the points using touchesBegan/Moved/Ended and placing them into an NSArray of UIBezierPaths.
Despite the name, UIBezierPath
doesn't just draw curves. In fact, by default it won't - presumably you're simply passing the coordinates returned by touchesBegan
etc, into the addLineToPoint
method.
Instead of simply passing all the touch coordinates directly into a UIBezierPath
you should first interpolate them to avoid these sharp lines that occur when you rapidly move your finger across the screen. This is not too difficult, although does require some knowledge of how bezier curves work and spline interpolation.
If you are looking for a slightly easier way out, there are a couple of open source libraries that will do this for you, like this one: http://cocoacontrols.com/platforms/ios/controls/smooth-line-view
精彩评论