quartz-graphics

put subviews of a UIView in front of its CALayer?

落爺英雄遲暮 提交于 2019-12-04 03:22:48
问题 Is this possible? Basically, I want to give my UIView a subview, and have that subview be in front of the view's layer (more specifically, in front of said layer's border). Of course I could achieve the effect I want by making two subviews of the view's superview, one on top of the other. But I'd rather avoid that if possible. 回答1: I looked for this for a while myself; i don't believe it is possible. I solved the issue by, as you hint at, adding the subview and the parent to the same

How to draw a circle starting at the top

允我心安 提交于 2019-12-04 01:15:32
问题 I'm working with some example code that draws an arc using CGPaths. I've had a look around and have found documentation but I just can't seem to visualize in my head whats going on in terms of using MoveToPoint, AddLineToPoint etc. I can't 'see' what the code is doing I can just see the result. For example the code below draws an arc a full 360 degrees beginning from the 3 o clock position. For the life of me I can't figure out how to make it begin from the 12 o clock position with actually

CGContextSetLineWidth(context, 1) - the width is almost alwayas at least 2 pixels instead 1

拈花ヽ惹草 提交于 2019-12-04 00:09:40
With CGContextSetLineWidth(context, 1) the width is almost alwayas at least 2 pixels instead 1 QQCandleStickLayer.m -(id)init { self = [super init]; if(self != nil) { self.delegate = self; self.opaque = NO; } return self; } - (void)drawLayer:(CALayer*)layer inContext:(CGContextRef)context{ CGContextSetLineWidth(context, 1.0f); CGContextSetAllowsAntialiasing(context, false); CGContextSetShouldAntialias(context, false); CGContextSetInterpolationQuality(context,kCGInterpolationNone); CGContextSetShadowWithColor(context, CGSizeMake( 0.0, 0.0 ), 0, NULL); CGContextMoveToPoint(context, self.bounds

CALayer delegate method drawLayer not getting called

99封情书 提交于 2019-12-04 00:02:41
My object a sub class of NSObject has CALayer instance variable. I use it for drawing and caching content with its delegate set to my object. But for some reason drawLayer:inContext: method NEVER gets called. Whereas actionForLayer:forKey: delegate method does get called implying the delegate is getting set properly with layer.delegate = self in the object's init method. Any suggestions on what is preventing my layer drawing method drawLayer:inContext: from getting called ? I am called the [layer setNeedDisplay] often. So I guess it is some fundamental error. drawLayer:inContext: won't get

How to scan links in a PDF document?

一笑奈何 提交于 2019-12-03 22:45:21
How can I scan links in a PDF Document? Do I have to use Quartz? Which methods/functions? Yes, you need to use Quartz. You have to parse it out from the PDF. This guide can help you. http://developer.apple.com/library/ios/#documentation/GraphicsImaging/Conceptual/drawingwithquartz2d/dq_pdf_scan/dq_pdf_scan.html#//apple_ref/doc/uid/TP30001066-CH220-TPXREF101 I recommend reading the PDF specification so you will know what to look for. The links are stored in the Annotations object so you will need some software to parse those. 来源: https://stackoverflow.com/questions/3717775/how-to-scan-links-in

How can I save a Bitmap Image, represented by a CGContextRef, to the iPhone's hard drive?

亡梦爱人 提交于 2019-12-03 22:28:39
I have a little sketch program that I've managed to throw together using Quartz2D, but I'm very new to the iOS platform and I'm having trouble figuring out how to allow the user to save their sketch. I have a CGContextRef that contains the sketch, how can I save it so that it can later be retrieved? Once it's saved, how can I retrieve it? Thanks so much in advance for your help! I'm going to continue reading up on this now... There are different types of CGContexts. You are most likely having a screen based context, but you would need either a bitmapContext or a pdfContext, to create a bitmap

Siri chat bubble color's in iOS

别来无恙 提交于 2019-12-03 21:14:04
I tried creating the Siri chat bubble in core graphics. I am at a stage where I can draw the shape. I am stuck with the color's here. Wanaa get the border color and the fill color code. here is what I did so far.. - (void)drawInContext:(CGContextRef)context { CGRect rect = gradientRectFrame; CGFloat radius = 30; CGFloat originBufferX = 0.0; CGFloat originBufferY = 0.0; CGFloat rightAngleTriangleWidth = 20.0; CGFloat rightAngleTriangleHeight = 20.0; CGFloat fullRectWidth = rect.size.width; CGFloat fullRectHeight = rect.size.height; CGPoint pointZero = CGPointMake(originBufferX, fullRectHeight);

How to draw signature with lines on iPhone screen?

点点圈 提交于 2019-12-03 21:08:13
I want to let user draw a signature on iPhone screen, so I add a subclass of UIView and add some code to its 'touchesMoved' method. -(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *touch = [touches anyObject]; firstTouch = [touch locationInView:self]; CGSize mySize = CGSizeMake(5, 5); UIGraphicsBeginImageContext(mySize); CGContextRef ctx = UIGraphicsGetCurrentContext(); CGContextBeginPath(ctx); CGContextSetRGBFillColor(ctx, 1, 0, 0, 1); CGContextAddRect(ctx, CGRectMake(0, 0, 5, 5)); CGContextFillPath(ctx); UIImage *redRect = UIGraphicsGetImageFromCurrentImageContext()

Why there is an invalid context error?

纵然是瞬间 提交于 2019-12-03 18:09:59
问题 Here is the code I use to draw: - (void) drawSomething { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSetRGBStrokeColor(context, 1, 0, 0, 1); CGContextSetLineWidth(context, 6.0); CGContextMoveToPoint(context, 100.0f, 100.0f); CGContextAddLineToPoint(context, 200.0f, 200.0f); CGContextStrokePath(context); NSLog(@"draw"); } But I got the error like this: [Session started at 2010-04-03 17:51:07 +0800.] Sat Apr 3 17:51:09 MacBook.local MyApp[12869] <Error>:

Create the indented look found in UINavigationBarButton - programmatically

╄→гoц情女王★ 提交于 2019-12-03 17:16:48
I'm trying to programmatically recreate the indented button look that can be seen on a UINavigationBarButton. Not the shiny two tone look or the gradient, just the perimeter shading: It looks like an internal dark shadowing around the entire view perimeter, slightly darker at the top? And then an external highlighting shadow around the lower view perimeter. I've played a bit with Core Graphics, and experimented with QuartzCore and shadowing with view.layer.shadowRadius and .shadowOffset, but can't even get the lower highlighting to look right. I'm also not sure where to start to achieve both a