cgpath

CGPath with outline

断了今生、忘了曾经 提交于 2019-12-23 07:47:02
问题 I am trying to draw a CGPath that has a stroke for it's stroke. Basically I want a draw a line using CGPath. I then want to go back and draw lines on both sides of the last CGPath giving it the effect that it is outlines. This line can bend and turn in any way but I always need the two lines on the outside to follow. EDIT: I need to be able to make the middle of the line transparent but the outlines solid black. 回答1: Use CGPathCreateCopyByStrokingPath to create a new path by stroking your old

Why CGPath and UIBezierPath define “clockwise” differently in SpriteKit?

别来无恙 提交于 2019-12-22 10:08:15
问题 In SpriteKit, the clockwise direction is reversed for UIBezierPath but not for CGPath . For example, if I have do { let path = CGPathCreateMutable() CGPathAddArc(path, nil, 0, 0, 10, 0, CGFloat(M_PI_2), true) let node = SKShapeNode(path: path) node.position = CGPoint(x: self.size.width/2, y: self.size.height/2) self.addChild(node) } do { let path = UIBezierPath() path.addArcWithCenter(CGPoint(x: 0, y: 0), radius: 10, startAngle: 0, endAngle: CGFloat(M_PI_2), clockwise: true) let node =

Can't set shadow on UICollectionViewCell and have rounded corners. Can only make one work at a time

陌路散爱 提交于 2019-12-22 09:21:03
问题 I have a UICollectionViewCell subclass and I need to round its corners and add a shadow as well. The cell looks like a square card, and the cells have a good amount of space in-between them. So "underneath" every cell, I would like to add some shadow. I can successfully do this, but then my cell only has rounded corners on the bottom. The top just has normal corners. I need rounded corners for all four corners. I have found solutions on here for UIViews that recommend adding a separate UIView

Combining Intersecting CGPaths on iOS

冷暖自知 提交于 2019-12-21 05:09:06
问题 I have a problem in an app I'm working on. Say I have two CGPaths that are fairly complex and I add them both to a CGMutablePath (thus combining them). Well, where the two paths intersect there will be points inside of each other. I want to eliminate those inside points and essentially draw the outside or outline of the path. I am having difficulty figuring out how I would go about this. Edit: Here's an example of what I am talking about. The blue and red boxes represent points along the

CGPath is not detected properly in cocos2d

∥☆過路亽.° 提交于 2019-12-20 02:56:14
问题 Through help and suggestions, I created a path for my sprite so that only the non-transparent parts can be touched. This is the path I came up with: path = CGPathCreateMutable(); CGPathMoveToPoint(path, NULL, endTouch.x, endTouch.y); CGPathAddLineToPoint(path, NULL, 0, 250); CGPathAddLineToPoint(path, NULL, 30, 0); CGPathCloseSubpath(path); This works for all my other classes except for one. No matter where I tap, xcode keeps printing "outside" using this code: for(int i = 0; i < [sprArray

Get UIBezierPath Stroke's Outline Path

百般思念 提交于 2019-12-20 02:26:12
问题 I have a UIBezierPath stroke, now I want to get the stroke's outline path(not the stroke's path itself), is there a way I could get that? or at least NSLog the UIBezierPath stroke's outline path? Thanks 回答1: You can use CGPathCreateCopyByStrokingPath for this. UIBezierPath *path = ...; CGFloat lineWidth = 10; CGPathRef cgStrokedPath = CGPathCreateCopyByStrokingPath(path.CGPath, NULL, lineWidth, kCGLineCapRound, kCGLineJoinRound, 0); UIBezierPath *strokedPath = [UIBezierPath

Get CGPath from Text

牧云@^-^@ 提交于 2019-12-18 18:07:21
问题 Hej fellows, I'm currently trying to convert a letter and/or multiple of them to a CGPathRef for manually drawing them into a custom UIView. I tried the way over CoreText and Framesetters including this little snippet but it doesn't seem to work.... NSAttributedString *stringToDraw = [[NSAttributedString alloc] initWithString:content attributes:nil]; // now for the actual drawing CGContextRef context = UIGraphicsGetCurrentContext(); // flip the coordinate system // draw CTFramesetterRef

Frame and Bounds of CAShapeLayer

删除回忆录丶 提交于 2019-12-18 13:19:19
问题 I am working on CAShapeLayer .And trying to draw non-linear path.I want to set frame to CAShapeLayer .So i can use CGPathGetPathBoundingBox method to get frame from CGPathRef . Here is code : CGMutablePathRef path = CGPathCreateMutable(); CGPathAddArc(path, NULL, rect.size.width/2, rect.size.height/2, 100, (0), (M_PI_2), NO); CGPathAddArc(path, NULL, rect.size.width/2, rect.size.height/2, 100-50, (M_PI_2), (0), YES); CGPathCloseSubpath(path); CAShapeLayer* arcLayer = [[CAShapeLayer alloc]init

Scale CGPath to Fit UIVIew

妖精的绣舞 提交于 2019-12-18 12:19:29
问题 I need to know how I can scale down or up CGPath so it can fit UIView? Set the background color to yellow, To see the view clearly self.frame = CGRectMake(0, 0, 181, 154); self.backgroundColor = [UIColor yellowColor]; Draw CAShapeLayer CAShapeLayer *shape = [CAShapeLayer layer]; shape.path = aPath; shape.strokeColor = [[UIColor blueColor] CGColor]; shape.lineWidth = 5; shape.fillColor = [[UIColor clearColor] CGColor]; [self.layer addSublayer:shape]; Then I get This: What I want is this: Thank

Efficient method to draw a line with millions of points

被刻印的时光 ゝ 提交于 2019-12-17 17:33:17
问题 I'm writing an audio waveform editor in Cocoa with a wide range of zoom options. At its widest, it shows a waveform for an entire song (~10 million samples in view). At its narrowest, it shows a pixel accurate representation of the sound wave (~1 thousand samples in a view). I want to be able to smoothly transition between these zoom levels. Some commercial editors like Ableton Live seem to do this in a very inexpensive fashion. My current implementation satisfies my desired zoom range, but