cgpath

How to animate CAShapeLayer path and fillColor

偶尔善良 提交于 2019-12-17 15:44:23
问题 How to animate CAShapeLayer path and fillColor? How to animate strokeEnd to show the path being drawn? and how to animate fillColor? 回答1: To animate path //setup the CAShapeLayer myShapeLayer.strokeColor = [[UIColor blueColor] CGColor]; myShapeLayer.lineWidth = 5; myShapeLayer.fillColor = [[UIColor yellowColor] CGColor]; //Display it! [self.view.layer addSublayer:myShapeLayer]; //Animate path CABasicAnimation *pathAnimation = [CABasicAnimation animationWithKeyPath:@"strokeEnd"]; pathAnimation

Where and how to __bridge

社会主义新天地 提交于 2019-12-17 15:17:22
问题 I need some advice on __bridge -ing in iOS. Hopefully the SSCCE 1 below will explain the problem better than I can in words, but I need to know how I can convert a void* to an NSMutableArray* ; which __bridge variation should be used (See comment in code). Reading about the different bridges, I deduced that I would need __bridge_transfer but then I receive an EXC_BAD_ACCESS on addObject: Ultimately, I'd like to have an array of the CGPoints in the CGPath after CGPathApply has been called.

Get path to trace out a character in an iOS UIFont

只愿长相守 提交于 2019-12-17 08:59:10
问题 Suppose I have a custom font "Foo" that I'm using in my iOS App. I've added it to my project, plist, etc. and I'm able to render UILabel s and such with it just fine. Now, if I want to find out a sequence of points that would "trace out" the letter 'P' in that font, how would I get that sequence of points? For example, suppose I wanted to use a CGPath to draw the letter 'P' slowly like a plotter would ... I just need a sequence of CGPoints in an array that if drawn as a path would draw a 'P'.

Getting issue in CGPath Scale

血红的双手。 提交于 2019-12-13 14:35:09
问题 I am drawing polygon using CGPath and adding to CAShapeLayer .I want to scale my CGPath when user click on it. I know how to scale CGPath . But when i click my CGPath , my CGPath drawing far from centre while i am drawing polygon in centre. CGAffineTransform scaleTransform = CGAffineTransformMakeScale(scaleFactor, scaleFactor); CGPathRef oldPath = polygonLayer.path; CGPathRef scaledPath = CGPathCreateCopyByTransformingPath(oldPath, &scaleTransform); polygonLayer.path = scaledPath; 回答1: The

Detecting Touch on SKShapeNode that is a Line

天大地大妈咪最大 提交于 2019-12-13 07:39:12
问题 I have an SKShapeNode that I have created and given a CGPath to. This is in my GameScene.swift in didMoveToView: let myNode = SKShapeNode() let lineToDraw = CGPathCreateMutable() CGPathMoveToPoint(lineToDraw, nil, 0, 0) CGPathAddLineToPoint(lineToDraw, nil, 87, 120) myNode.path = lineToDraw myNode.strokeColor = SKColor.redColor() myNode.lineWidth = 20 myNode.name = "My Node!" world.addChild(myNode) // World is a higher-level node in my scene And this is how I'm detecting touches, again in the

Generate a CGPath from another path's line width outline

荒凉一梦 提交于 2019-12-11 08:28:43
问题 I might not be explaining this in the best way possible, so please bear with me. What I have is a drawn CGPath on top of a MKMapView object: The way I was able to achieve this is to create a CGPath for the darker blue line, then create a copy of that path, and then stroke a thicker version of it with a semi-transparent blue color. Here's the code that I'm currently using for this: // set the shadow around the path line CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState

How to create a multiline string or multiline label as a CGPath in iOS?

烂漫一生 提交于 2019-12-11 02:24:55
问题 Does the API support this? If not, how could I do it? There is CTFontCreatePathForGlyph in Core Text, which can translate a single character into a path. I could use that in a loop to create my string as a path, but I'd have to deal with spacing and kerning and all the other nasty things. I'm looking for a string path that would looks the same if it was drawn in a UILabel with same font and size. 回答1: There is an article called Low-level text rendering by Ohmu that covers this pretty

How to reverse the point order of a CGPath

只谈情不闲聊 提交于 2019-12-10 18:38:19
问题 I want to draw a Circle with Letter punched out of it. to do this, I need to stroke the circle clockwise and the letter counterclockwise. That is all good and well, but when I get the letter path using Core Text I can't figure out how to essentially reverse the path. NOT MIRROR or ROTATE or anything...that is straightforward enough. I want the point stroke order to be counterclockwise. it is actually hilariously difficult. I've had entirely too many visual 'off by one' errors. 回答1: About all

Cannot release path created by CGPathCreateMutable in Swift

☆樱花仙子☆ 提交于 2019-12-10 16:28:37
问题 I have this simple code in Swift: override var bounds : CGRect { didSet { if (bounds != oldValue) { var path = CGPathCreateMutable() CGPathAddEllipseInRect(path, nil, bounds) self.path = path CGPathRelease(path) } } } It's supposed to draw a circle that fills the layer when the layer's bounds changes. This is ported from my old Objective-C code, which works fine: - (void)setBounds:(CGRect)bounds { if (CGRectEqualToRect(self.bounds, bounds)) return; super.bounds = bounds; CGMutablePathRef path

Clearing CGPath path after drawing is done

大兔子大兔子 提交于 2019-12-10 10:24:14
问题 I've written a program for drawing in iOS in touchesMoved() method. CGContextAddPath(UIGraphicsGetCurrentContext(), path); CGPathMoveToPoint(path, NULL, lastPoint.x, lastPoint.y); CGPathAddLineToPoint(path, NULL, lastPoint.x, lastPoint.y); CGContextDrawPath(UIGraphicsGetCurrentContext(), kCGPathStroke); How can i clear the path drawn and restore the original view? 回答1: Perhaps you can put an invisible view above your view of drawing and add the path traced by the user only when u are sure