uibezierpath

Crazy rounded rect UIBezierPath behavior on iOS 7. What is the deal?

主宰稳场 提交于 2019-11-30 05:33:30
问题 The simple UIView below draws a rounded rectangle. When I pass a corner radius of 65 or below it rounds correctly, but 66 and above and it generates a perfect circle! What is going on here? It should only show a circle when the corner radius is equal to 1/2 the frame width, but it seems that it is drawing a circle when the radius is about 1/3rd, no matter what the size of the view is. This behavior appears on iOS 7. On iOS 6 I get expected behavior. #import "ViewController.h" @interface

Animating Bezier curve as though drawing proceeds on iPhone screen

不问归期 提交于 2019-11-30 05:21:55
I want to draw a bezier path of the outline of Taj Mahal's tomb. Q1. How could I draw it in XCode? I could easily do that in PS but am finding it difficult to do in XCode programmatically especially getting the coordinates of the control points. Q2. Moreover, how can the coordinates of the points be fixed when the screen sizes vary? Q3. How could I animate it as though an invisible pencil is drawing that on screen? How do I draw a bezier path in UIKit ? Create a UIBezierPath object and then use the various methods on it to construct your path . I suspect the methods you're going to be most

clip-masking uiview with CAShapeLayer and UIBezierPath

自闭症网瘾萝莉.ら 提交于 2019-11-30 03:57:45
问题 I have a problem clipping a view using CAShapeLayer-UIBezierPath , I want to clip the content but I end up getting a stroke (frame) with that UIBezierPath , This is my code UIBezierPath *path2Path = [UIBezierPath bezierPath]; [path2Path moveToPoint:CGPointMake(206.745, 0)]; [path2Path addLineToPoint:CGPointMake(206.745, 97.613)]; [path2Path addLineToPoint:CGPointMake(0, 97.613)]; [path2Path addLineToPoint:CGPointMake(0, 0)]; [path2Path addLineToPoint:CGPointMake(87.28, 0)]; [path2Path

Why is cornerRadii parameter of CGSize type in -[UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:]?

自作多情 提交于 2019-11-30 03:45:29
I can't figure this out... I'm playing with -[UIBezierPath bezierPathWithRoundedRect:byRoundingCorners:cornerRadii:] as such: bezierPath = [UIBezierPath bezierPathWithRoundedRect:CGRectMake(10, 10, 80, 80) byRoundingCorners:(UIRectCornerBottomLeft) cornerRadii:CGSizeMake(20, 20)]; And it works as expected. But if I replace cornerRadii:CGSizeMake(20, 20) with, say, cornerRadii:CGSizeMake(20, 5) or CGSizeMake(20, 40) , there's no difference. Why is cornerRadii CGSize and not CGFloat then? What is CGSize.height for? Any ideas and advice will be greatly appreciated :) I can now confirm that this

UIBezierPath round edges?

*爱你&永不变心* 提交于 2019-11-30 03:09:46
问题 Im drawing some lines and I noticed that when the edges get at a certain angle it generates a sharp edge like this: What I want it to draw: How do I do this? I have looked through the documentations but I dont seem to find anything im looking for. Or is there a way to turn that auto-edge-generating off? 回答1: UIBezierPath's have a property called lineJoinStyle . Set it to kCGLineJoinRound and it will draw as you want it. UIBezierPath *myPath = ... myPath.lineJoinStyle = kCGLineJoinRound; 回答2:

Get CGPath total length

人走茶凉 提交于 2019-11-30 00:34:38
I have many UIBezierPath that I am animating with CALyerAnimation @"StrokeStart" and @"strokeEnd". I wish that the animation will have the same speed for all the paths so I thougt I might use the length of the path in : DISTANCE / TIME = SPEED Is there a way to calculate the path "length" ? Thanks Shani While you can calculate Bezier path's length by integrating it numerically, it can be done much easier by dividing path into linear segments. If the segments are small enough the approximation error should be neglectable, especially that you are just trying to animate it. I'll show you function

Why does giving addArcWithCenter a startAngle of 0 degrees make it start at 90 degrees?

不羁岁月 提交于 2019-11-29 23:32:46
I'm creating a CAShapeLayer to use as a mask for a UIView 's layer. I'm using a UIBezierPath to draw the shape layer. It's working fine, except I'm getting some odd results when I draw. The geometry is not behaving as expected. I'm trying to draw simple "pie slice" in the upper right corner: #define degreesToRadians(x) ((x) * M_PI / 180.0) ... // "layer" refer's to the UIView's root layer CAShapeLayer *maskLayer = [CAShapeLayer layer]; maskLayer.frame = layer.presentationLayer ? ((CAGradientLayer *)layer.presentationLayer).bounds : layer.bounds; maskLayer.fillRule = kCAFillRuleEvenOdd;

Draw gradient along a curved UIBezierPath

自闭症网瘾萝莉.ら 提交于 2019-11-29 22:32:33
In an app, I draw a curved UIBezierPath an an MKOverlayPathView class to show flight routes. This is the code I am using: - (UIBezierPath *)pathForOverlayForMapRect:(MKMapRect)mapRect { ... bla bla bla ... UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:s]; [path addQuadCurveToPoint:e controlPoint:cp1]; [path addLineToPoint:e2]; [path addQuadCurveToPoint:s2 controlPoint:cp2]; [path closePath]; return path; } - (void)drawMapRect:(MKMapRect)mapRect zoomScale:(MKZoomScale)zoomScale inContext:(CGContextRef)context{ self.mapRect = mapRect; CGContextSetRGBFillColor(context, 1.0, 1

iPhone iOS Generate star, sunburst or polygon UIBezierPath programmatically

守給你的承諾、 提交于 2019-11-29 14:42:28
问题 I'm looking for a way to programmatically create stars, sunburst, and other "spiky" effects using UIBezierPath. UIBezierPath *sunbeamsPath = [UIBezierPath bezierPath]; [sunbeamsPath moveToPoint: CGPointMake(x, y)]; Are there any algorithms that can generate points for sunburst like shapes programmatically, without paths overlapping? I'm also interested in an irregular shape sunburst like the one below: I would imagine that such algorithm would take a certain number of rays, then roughly

How to draw Bezier curves with native Javascript code without ctx.bezierCurveTo?

北慕城南 提交于 2019-11-29 12:16:20
问题 I need to draw and get coordinates of bezier curves of each steps with native Javascript without ctx.bezierCurveTo method. I found several resources, but I confused. Esspecially this looks pretty close, but I couldnt implemented clearly. How can I accomplish this? 回答1: You can plot out the Bezier: bezier = function(t, p0, p1, p2, p3){ var cX = 3 * (p1.x - p0.x), bX = 3 * (p2.x - p1.x) - cX, aX = p3.x - p0.x - cX - bX; var cY = 3 * (p1.y - p0.y), bY = 3 * (p2.y - p1.y) - cY, aY = p3.y - p0.y -