uibezierpath

Draw Graph curves with UIBezierPath

萝らか妹 提交于 2019-11-27 06:30:51
I'm drawing a graph in my application. My problem is that I want to draw line joining vertex points as curves. Currently I'm drawing them with UIBezierPath 's function addLineToPoint: . I want to draw them as curves. I'm well aware that UIBezierPath has following two functions to support this feature. Cubic curve: addCurveToPoint:controlPoint1:controlPoint2: Quadratic curve: addQuadCurveToPoint:controlPoint: But problem is that I don't have control points. All i have is two end points. Neither I found a method/formula to determine control points. Can anyone help me here? I will appreciate if

How to Animate a UIBezierPath

百般思念 提交于 2019-11-27 06:30:42
i would like to animate a UIBezierPath of a rect to a triangle one, not to animate a view on a path but animate the path itself so it morphs from one shape to another. the path is added to a CALayer CAShapeLayer *maskLayer = [CAShapeLayer layer]; maskLayer.fillColor = [[UIColor whiteColor] CGColor]; maskLayer.path = [self getRectPath]; -(CGPathRef)getTrianglePath { UIBezierPath* triangle = [UIBezierPath bezierPath]; [triangle moveToPoint:CGPointZero]; [triangle addLineToPoint:CGPointMake(width(self.view),0)]; [triangle addLineToPoint:CGPointMake(0, height(self.view))]; [triangle closePath];

UIBezierPath Subclass Initializer

强颜欢笑 提交于 2019-11-27 06:22:34
问题 I'm trying to create a subclass of UIBezierPath to add some properties that are useful to me. class MyUIBezierPath : UIBezierPath { var selectedForLazo : Bool! = false override init(){ super.init() } /* Compile Error: Must call a designated initializer of the superclass 'UIBezierPath' */ init(rect: CGRect){ super.init(rect: rect) } /* Compile Error: Must call a designated initializer of the superclass 'UIBezierPath' */ init(roundedRect: CGRect, cornerRadius: CGFloat) { super.init(roundedRect:

UIBezierPath Triangle with rounded edges

跟風遠走 提交于 2019-11-27 06:04:06
I have designed this code to generate a Bezier Path that is used as a path for a CAShapeLayer to mask a UIView (the view's height and width are variable) This code generates a triangle with sharp edges, but I would like to make it round cornered! I have spent a good 2 hours trying to work with addArcWithCenter... , lineCapStyle and lineJoinStyle etc but nothing seems to work for me. UIBezierPath *bezierPath = [UIBezierPath bezierPath]; CGPoint center = CGPointMake(rect.size.width / 2, 0); CGPoint bottomLeft = CGPointMake(10, rect.size.height - 0); CGPoint bottomRight = CGPointMake(rect.size

Removing lagging latency in drawing UIBezierPath smooth lines in Swift

余生颓废 提交于 2019-11-27 02:58:52
问题 The code below draws smooth curved lines by overriding touches, but there is noticeable lagging or latency. The code uses addCurveToPoint and calls setNeedsDisplay after every 4 touch points which causes a jumpy appearance as the drawing doesn't keep up with finger movements. To remove the lagging or perceived latency, touch points 1, 2, 3 (leading up to touch point 4) could be temporarily filled with addQuadCurveToPoint and addLineToPoint . How can this actually be achieved in code to remove

How to draw a “speech bubble” on an iPhone?

落爺英雄遲暮 提交于 2019-11-27 02:44:25
I'm trying to get a "speech bubble" effect similar to the one in Mac OS X when you right click on something in the dock. Here's what I have now: I need to get the "triangle" part of the lower portion. Is there any way I can draw something like that and get a border around it? This will be for an iPhone app. Thanks in advance! EDIT: Many thanks to Brad Larson, here's what it looks like now: I've actually drawn this exact shape before (rounded rectangle with a pointing triangle at the bottom). The Quartz drawing code that I used is as follows: CGRect currentFrame = self.bounds;

How to create a UIImage with UIBezierPath

◇◆丶佛笑我妖孽 提交于 2019-11-27 02:01:43
问题 I wrote some code to create a UIImage with UIBezierPath but it didn't work. Can someone help me find out what's wrong with my code? -(UIImage*) drawTriangle{ CGRect rect = CGRectMake(0.0, 0.0, 30.0, 30.0); UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); UIGraphicsPushContext(context); UIBezierPath *bezier = [UIBezierPath bezierPathWithRect:rect]; [bezier moveToPoint:CGPointMake(25, 5)]; [bezier addLineToPoint:CGPointMake(5, 15)]; [bezier

UIBezierPath Subtract Path

血红的双手。 提交于 2019-11-26 23:50:48
By using [UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:] , I am able to create a rounded view, such as this: How could I subtract another path from this one (or some other way), to create a path like this: Is there any way I can do something like this? Pseudocode: UIBezierPath *bigMaskPath = [UIBezierPath bezierPathWithRoundedRect:bigView.bounds byRoundingCorners:(UIRectCornerTopLeft|UIRectCornerTopRight) cornerRadii:CGSizeMake(18, 18)]; UIBezierPath *smallMaskPath = [UIBezierPath bezierPathWithRoundedRect:smalLView.bounds byRoundingCorners:(UIRectCornerTopLeft

How to fill a UIBezierPath with a gradient?

若如初见. 提交于 2019-11-26 22:30:39
I've drawn a graph using a UIBezierPath. I can fill the area under the graph with a solid color but I want to fill the area under the graph with a gradient rather than with a solid color. But I'm not sure how to make the gradient apply only to the graph and not to the whole view, I've read a few questions but not found anything applicable. This is the main graph drawing code: // Draw the graph UIBezierPath *barGraph = [UIBezierPath bezierPath]; barGraph.lineWidth = 1.0f; [blueColor setStroke]; TCDataPoint *dataPoint = self.testData[0]; CGFloat x = [self convertTimeToXPoint:dataPoint.time];

addArc(withCenter) closing path

让人想犯罪 __ 提交于 2019-11-26 22:02:26
问题 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