uibezierpath

Create a circle with multi coloured segments in Core Graphics

♀尐吖头ヾ 提交于 2019-12-19 11:56:48
问题 I am trying to draw a pie chart which will be made up of equal sized segments, each with a different colour. I am basing my code off this SO: Draw a circular segment progress in SWIFT let circlePath = UIBezierPath(ovalInRect: CGRect(x: 200, y: 200, width: 150, height: 150)) var segments: [CAShapeLayer] = [] let segmentAngle: CGFloat = 1.0 / CGFloat(totalSegments) for var i = 0; i < totalSegments; i++ { let circleLayer = CAShapeLayer() circleLayer.path = circlePath.CGPath // start angle is

Draw Line Using UIPinchGeustureRecognizer

时光总嘲笑我的痴心妄想 提交于 2019-12-19 11:42:50
问题 I want to draw line using UIPinchGeustureRecognizer,I have tried all stackoverflow solution but no luck. please help me to resolve this. I am getting following error First i want to know my code logic is correct or not.and i didnt get the points from touchbegan/touchmoved. i am gettting two points from (void)handleLinePinch:(UIPinchGestureRecognizer *)gesture only. //My instances in .h file CGPoint location1,location2; LineView* l; - (void)viewDidLoad { [super viewDidLoad]; l = [[LineView

Undestanding UIBezierPath curving mechanism, controlPoint and the curve point

烈酒焚心 提交于 2019-12-19 09:24:40
问题 I'm trying to draw a simple Parabola shape using UIBezierPath . I have a maxPoint and a boundingRect of which I'm basing the width and stretch of the parabola. Here's the function I made to draw the parabola (I draw the parabola in a container view, rect will be container.bounds ): func addParabolaWithMax(maxPoint: CGPoint, inRect boundingRect: CGRect) { let path = UIBezierPath() let p1 = CGPointMake(1, CGRectGetMaxY(boundingRect)-1) let p3 = CGPointMake(CGRectGetMaxX(boundingRect)-1,

How to Crop the UIView with repeated semi circle?

Deadly 提交于 2019-12-19 04:44:30
问题 I want to crop an UIView with bottom and top of repeated semi circle like this image 回答1: I had been working on your question and here is my results, you need create a UIBezierPath and apply to your desired view, use this code for that Function to generate the desired BezierPath func pathSemiCirclesPathForView(givenView: UIView, ciclesRadius:CGFloat = 10, circlesDistance : CGFloat = 2) ->UIBezierPath { let width = givenView.frame.size.width let height = givenView.frame.size.height let

Animating a bezier curve point

一个人想着一个人 提交于 2019-12-18 18:30:02
问题 I'm trying to animate a bezier curve I made with Paintcode (great app, btw) and am drawing in a custom UIView in the "drawRect" method. The drawing works fine but I want to animate a single point in the bezier curve. Here's my non-working method: -(void)animateFlame{ NSLog(@"Animating"); // Create the starting path. Your curved line. //UIBezierPath * startPath; // Create the end path. Your straight line. //UIBezierPath * endPath = [self generateFlame]; //[endPath moveToPoint: CGPointMake(167

Animating a bezier curve point

丶灬走出姿态 提交于 2019-12-18 18:29:31
问题 I'm trying to animate a bezier curve I made with Paintcode (great app, btw) and am drawing in a custom UIView in the "drawRect" method. The drawing works fine but I want to animate a single point in the bezier curve. Here's my non-working method: -(void)animateFlame{ NSLog(@"Animating"); // Create the starting path. Your curved line. //UIBezierPath * startPath; // Create the end path. Your straight line. //UIBezierPath * endPath = [self generateFlame]; //[endPath moveToPoint: CGPointMake(167

How to draw Signature on UIView

别等时光非礼了梦想. 提交于 2019-12-18 18:25:02
问题 I am new in ios.And I need to create a textview or label in which i can sign. Like this image. 回答1: You can draw signature on UIView for that first subclass UIView and your subclass of UIView should be something like, SignatureView.h #import <UIKit/UIKit.h> @interface SignatureView : UIView{ UIBezierPath *_path; } - (void)erase; @end SignatureView.m #import "SignatureView.h" @implementation SignatureView - (void)drawRect:(CGRect)rect { _path.lineCapStyle = kCGLineCapRound; [_path stroke]; } -

How to draw Signature on UIView

帅比萌擦擦* 提交于 2019-12-18 18:24:13
问题 I am new in ios.And I need to create a textview or label in which i can sign. Like this image. 回答1: You can draw signature on UIView for that first subclass UIView and your subclass of UIView should be something like, SignatureView.h #import <UIKit/UIKit.h> @interface SignatureView : UIView{ UIBezierPath *_path; } - (void)erase; @end SignatureView.m #import "SignatureView.h" @implementation SignatureView - (void)drawRect:(CGRect)rect { _path.lineCapStyle = kCGLineCapRound; [_path stroke]; } -

Get points from a UIBezierPath

坚强是说给别人听的谎言 提交于 2019-12-18 13:33:04
问题 I drew the above BezierPath by doing: // location is where the user touches screen. // location will be the maximum of the graph CGPoint origin = CGPointMake(xStart, 620.0); CGPoint endpt = CGPointMake(xEnd, 620.0); CGPoint midpt1 = midPointForPoints(origin, location); CGPoint midpt2 = midPointForPoints(location, endpt); UIBezierPath *path = [UIBezierPath bezierPath]; [path moveToPoint:origin]; [path addQuadCurveToPoint:location controlPoint:CGPointMake(midpt1.x, midpt1.y+50)]; [path

Drag ball over circle path in Swift

我的梦境 提交于 2019-12-18 13:14:55
问题 I made a circle Path, the center of the circle path is in the middle of the view. Then, I made a ball that can move only on the circle path (at least this is what I want it to be): I made a function that move the ball wherever I drag him (on the circle path only), but for some reason whenever I drag it, it gets crazy and doesn't move as I want it to move. This is my code so far: class ViewController: UIViewController { var midViewX = CGFloat() var midViewY = CGFloat() var circlePath2 =