문제

I am interested in making path with finger (like connecting objects) between two elements. I am not sure how would I start on this.

I know that I could use Bezier path to create lines, but I am not sure how to create that line with finger. Does anyone have some good example?

I tried to google it, but I can't find anything like that made.

Thanks

도움이 되었습니까?

해결책

I answered a question recently about slow/laggy performance on a similar setup. I.E. Drawing UIBezierPaths in CALayer. The answer contains a subclass of UIView which you can drop into a storyboard and will pretty much get you started. The header file is not shown in the answer, but it is literally a subclass of UIView (just add a UIView Subclass to your project). You should be able to copy the rest into your implementation file. Obviously you'll want to take out the performance testing code.

touchesMoved drawing in CAShapeLayer slow/laggy

If you simply want to Add a single line, you just need to get the starting point in touchesBegan, and build the path in touchesMoved. The commitCurrentRendering simply renders the touch points accumulated, then clears the UIBezierPath. This improves the performance as there wass a notable slowdown when UIBezierPath reached around 2000 points (touchesMoved will feed you a succession of points as your finger moves).

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top