I have made an application which draws a number of curves, using UIBezierPath. Now I'm trying to implement a modification functionality in it. To modify the particular curve one thing I can do is to draw all the curves again; I have not yet implemented this. But I think this algorithm would not be very efficient when the number of curves increases because I have to store all the points in the array and I have to run for loop to draw each curve every time I go for modification.
I am looking for more efficient algorithm. It will be helpful if someone can provide example code.
You can represent individual curves as UIBezierPath
s and draw them separately by creating one CAShapeLayer
per curve and assigning the shape layer's path
property to the corresponding CGPath
property of the bezier path. To update an individual curve, you then just have to manipulate one bezier path and the corresponding shape layers path
property.