uibezierpath

How to draw Smooth straight line by using UIBezierPath?

梦想的初衷 提交于 2019-12-08 03:37:58
问题 I want to be able to draw straight lines on my iPad screen using an UIBezierPath . How would I go about this? What I want to do is something like this: I double tap on the screen to define the start point. Once my finger is above the screen the straight line would move with my finger (this should happen to figure out where I should put my next finger so that it will create a straight line). Then, if I double tap on screen again the end point is defined. Further, a new line should begin if I

Create a UIView with rounded top edge

此生再无相见时 提交于 2019-12-08 03:30:25
问题 I would like to create an UIView with rounded top edge like this image, how can I do it please? Wanted result Not wanted result 回答1: To repost an answer I posted on a different thread: I can now confirm that this is a bug introduced after iOS 6. I have an old 4s running iOS 6.1. On that machine, this code: path = [UIBezierPath bezierPathWithRoundedRect: bounds byRoundingCorners: UIRectCornerTopLeft | UIRectCornerTopRight cornerRadii: CGSizeMake(bounds.size.width/2, bounds.size.width/6) ];

Bezier path see if it crosses

北战南征 提交于 2019-12-08 03:08:16
问题 I have a code that lets the user draw a shape, I'm using UIBezierPath for this. But I need to see if the shape crosses itself, for example like this: http://upload.wikimedia.org/wikipedia/commons/0/0f/Complex_polygon.svg Then it's not a a valid shape. How can I find this? Edit: I still haven't solved this. I save all the points between the lines in the path in a array. And then I loop through the array and try to find if any lines intersects. But it does not work, sometimes it says that there

Move UIView per UIBezierPath [closed]

一曲冷凌霜 提交于 2019-12-08 03:07:48
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 3 years ago . I've a UIBezierPath drawing this And I want the red point to move on the blue path infinitely (from right to left, from left to right) How can I do that? 回答1: You can use CAKeyFrameAnimation . Assign your path to the path property of the animation object, then run the animation on

UIBezierPath undo drawing redraw UIImageView's image

妖精的绣舞 提交于 2019-12-08 02:54:05
问题 I'm trying to redraw my UIImageView's image by redrawing all UIBezierPaths and associated UIColors in an NSMutableArray I have created, minus the last path when I tap an undo UIButton. However, the UIImageView's image doesn't redraw and remove the last path in this case, until the NSMutableArray's count is less than 2, in which it sets the UIImageView's image to nil (this is working correctly) I'd appreciate any help offered. Note: I'm not including my touchesMoved method because I just want

How to encode UIBezierPath to SVG?

感情迁移 提交于 2019-12-08 02:53:51
问题 I have a simple view for finger painting / drawing. I store the drawings as UIBezierPath s in a NSMutableArray . Now I want to transfer the drawings to a web-service for presenting them in a browser. Therefore I need to encode my UIBezierPath s in a SVG-file - because this the format of the web-service. What I found right now is the SVGKit, which only DECODES SVG. Do anybody know sample code, snippets or a framework for encoding SVG? Thank you. 回答1: I tested yet. but using following steps:

UIBezierPath appending overlapping isn't filled

拜拜、爱过 提交于 2019-12-07 23:45:48
问题 I'm trying to merge two overlapping UIBezierPaths using UIBezierPath.append , and I want the overlapping space to be filled. I tried setting the usesEvenOddFillRule property to false , but it still doesn't fill. Here is minimal example of the problem: override func draw(_ rect: CGRect) { let firstShape = UIBezierPath() firstShape.move(to: CGPoint(x: 100, y: 100)) firstShape.addLine(to: CGPoint(x: 100, y: 150)) firstShape.addLine(to: CGPoint(x: 150, y: 170)) firstShape.close() let secondShape

Draw sine wave with frequency?

Deadly 提交于 2019-12-07 19:54:51
问题 I am drawing one period of a sine wave with: let width = rect.width let height = rect.height let origin = CGPoint(x: width * (1 - graphWidth) / 2, y: height * 0.50) let path = UIBezierPath() path.move(to: origin) for angle in stride(from: 5.0, through: 360.0, by: 5.0) { let x = origin.x + CGFloat(angle/360.0) * width * graphWidth let y = origin.y - CGFloat(sin(angle/180.0 * Double.pi)) * height * amplitude path.addLine(to: CGPoint(x: x, y: y)) } Globals.sharedInstance.palleteGlowGreen

Draw letter(text) with UIBezierPath single line

这一生的挚爱 提交于 2019-12-07 19:01:37
问题 I am using this and this for reference. I am new for using UIBezierPath, and i want to draw path on character(letter) code i am using is as follow. CGMutablePathRef letters = CGPathCreateMutable(); CTFontRef font = CTFontCreateWithName(CFSTR("Courier New"), 200.0f, NULL); NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:CFBridgingRelease(font), kCTFontAttributeName,nil]; NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:@"B" attributes:attrs];

How can I draw a dot on the screen on touchesEnded using UIBezierpath

醉酒当歌 提交于 2019-12-07 05:32:13
问题 Can someone here please show me how to draw a single dot using UIBezierpath? I am able to draw a line using the UIBezierpath but if I remove my finger and put it back and then remove nothing get drawn on the screen. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; CGPoint p = [touch locationInView:self]; [pPath moveToPoint:p]; [pPath stroke]; [self setNeedsDisplay]; } - (void)drawRect:(CGRect)rect { [pPath stroke]; } 回答1: Your path doesn