uibezierpath

addArc(withCenter) closing path

隐身守侯 提交于 2019-11-28 02:27:44
The following code: let size = CGSize(width: 200, height: 30) let rect = CGRect(origin: .zero, size: size) let path1 = UIBezierPath() path1.move(to: CGPoint(x: 10, y: 5)) path1.addLine(to: CGPoint(x: 180, y: 5)) path1.addArc(withCenter: CGPoint(x: 180, y: 20), radius: 15, startAngle: (3.14159 / 2), endAngle: (3 * 3.14159 / 2), clockwise: false) produces this: Ok, am I missing something? I do not want to close this path. I never call path1.close() . I want to add another straight line from the end of the arc, not from the closed version of it. Basically, I don't want the half circle to be

How to create several UIButtons along a path/BezierCurve?

落爺英雄遲暮 提交于 2019-11-28 02:22:52
问题 How can I create objects along a path/BezierCurve? In other words, how can I create several UIButtons along a given path, with a given interval along that same path? I have seen dozens of questions about moving objects. But I need a solution to actually create them. I would like to go along the path and create an object for every X points/distance. Like this: ....@....@....@....@.... In this case, for every 4 points, get the position, and create a UIButton there. 回答1: iOS doesn't have a

touchesMoved drawing in CAShapeLayer slow/laggy

ぃ、小莉子 提交于 2019-11-28 01:15:38
问题 As was suggested to me in a prior StackOverflow question, I'm trying to improve my drawing method for letting my user draw lines/dots into a UIView. I'm now trying to draw using a CAShapeLayer instead of dispatch_async. This all works correctly, however, drawing into the CAShapeLayer continuously while touches are moving becomes slow and the path lags behind, whereas my old (inefficient I was told) code worked beautifully smooth and fast. You can see my old code commented out below. Is there

How to check if touch point is on UIBezierPath (iOS) [closed]

孤街醉人 提交于 2019-11-28 00:59:40
问题 Closed . This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 6 years ago . How could I know if a touch point (touchesBegan) is on a hidden UIBezierPath? 回答1: [bezierPath containsPoint:touchPoint]; Just make sure that your touch point is in the same coordinate system as the bezierPaths points and that the points are within the same context i.e. both in screen space. -

How can I erase UIBezierPath lines drawn on a transparent view above an image?

我的未来我决定 提交于 2019-11-27 23:02:13
问题 I am creating an app like whiteboard application. I have one dynamic image. Image has multiple colors. I want to draw line on that Image same as whiteboard so I had overlap a Transparent View on that. Now I am drawing line with chosen color that's working very well. Now the problem is when I try to erase the line when touch on screen it should show effects like eraser. If I has some fixed color (like white) background then for erasing line I can draw a line with background color but here I

Hit detection when drawing lines in iOS

自古美人都是妖i 提交于 2019-11-27 22:57:18
I would like to allow the user to draw curves in such a way that no line can cross another line or even itself. Drawing the curves is no problem, and I even found that I can create a path that is closed and still pretty line-like by tracing the nodes of the line forwards and back and then closing the path. Unfortunately, iOS only provides a test for whether a point is contained in a closed path (containsPoint: and CGPathContainsPoint). Unfortunately, a user can pretty easily move their finger fast enough that the touch points land on both sides of an existing path without actually being

How to Draw a Bezier Curve in UIView

前提是你 提交于 2019-11-27 22:38:48
问题 I need to make a curve in a UIView as displayed in the image below. I have to use UIBezierPath . Kindly help me out with this. I also want to know how to flip the curve from the horizontal axis, so that I have the arc at the top and the base at the bottom. 回答1: To draw a solid filled in arc within a particular CGSize , you can define a UIBezierPath like so: - (UIBezierPath * _Nullable)pathOfArcWithinSize:(CGSize)size { if (size.width == 0 || size.height <= 0) return nil; CGFloat theta = M_PI

How to simplify a single complex UIBezierPath polygon in iOS

為{幸葍}努か 提交于 2019-11-27 22:27:34
问题 Problem: I have a user generated polygon (via registering user's touches on screen) which can be simple or complex (complex means having unknown number of intersections) and I want to have a simple polygon resulting from the same points on the original polygon, something like an outline or a contour if you will. Possible solutions: I have found this, but it is a JavaScript solution and this is a perfect illustration of what I need but in ActionScript! I don't need the Path itself, the points

finding a point on a path

谁说我不能喝 提交于 2019-11-27 18:40:53
问题 I have an app that draws a bezier curve in a UIView and I need to find the X intersect when I set a value for Y. First, as I understand, there isn’t a way to find a point directly of a UIBezierPath but you can locate a point of a CGPath . First, if I “stroke” my UIBezierPath (as I have done in my code) is this actually creating a CGPath or do I need to take further steps to actually convert this to a CGPath ? Second, I want to find the curves intersect at X by providing the value for Y. My

How to effectively process UITouches in a multitouch sequence

我的未来我决定 提交于 2019-11-27 15:52:38
I am working with multitouch while writing, So basically what I am doing is, I am writing with hand support, because typically, its how user writes, I followed this link How to ignore certain UITouch Points in multitouch sequence Everything is working fine with single touch, but their is some problem when I write with my hand touching the screen i.e multiple UItouches Below is my code In touches began, I go through all touches and I find the touch with highest y position, below is my code Below is my code -(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { UITouch* topmostTouch =