quartz-graphics

Change animation time for properties of a CALayer

霸气de小男生 提交于 2019-12-03 09:51:32
问题 I have a CALayer to animate a change in its image contents. Now, how can I change how long it takes for this animation to take place? 回答1: It's more or less simple. You have an ivar CALayer *yourLayer . Then you set the delegate and implement the delegate method -(id<CAAction>)actionForLayer:forKey: - (void)awakeFromNib { yourLayer.delegate = self; yourLayer.name = @"yourLayer"; } - (id <CAAction>)actionForLayer:(CALayer *)layer forKey:(NSString *)event { if([layer.name isEqualToString

iPhone OS 3.2; PDF rendering; User Interaction

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-03 08:27:54
I'd need to create a iPad-app which would be rendering multiple PDF-Files (one file contains one page). Each page should be scrollable, zoomable and if the user taps on a part of the PDF a website or photo gallery should popup. Currently i think i could do that either with: A. UIWebView Displays the pdf's nicely, scrolling and zooming works. But it looks like a lot of trouble to realize the clickable parts of the PDF. I don't know if i could use CGPDFContextSetURLForRect Getting the touch-events from UIWebView to do something like CGPDFContextSetURLForRect my self looks like it would be some

CGImage (or UIImage) from a CALayer

≯℡__Kan透↙ 提交于 2019-12-03 08:22:20
I have created a CALayer (I added several shapes to the layer, but ultimately, I have a single CALayer), and I am having a LOT of trouble adding it to a CGImage. I have found some references to [CALayer renderInContext:ctx] , but I am not sure how to implement it. Has anyone done this before? Try this... UIGraphicsBeginImageContext(layer.bounds.size); [layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); Create a bitmap graphics context and use renderInContext: to draw the layer into it. You now have

How to add a CALayer to an NSView on Mac OS X

别说谁变了你拦得住时间么 提交于 2019-12-03 06:55:32
问题 I'm trying to learn how to use and implement CALayer in a Mac Objective-C application, but I can't seem to probably do the most basic thing - add a new layer and set its background colour/frame size. Can anyone see what is wrong with my code? CALayer *layer = [CALayer layer]; [layer setFrame:CGRectMake(0, 0, 100, 100)]; [layer setBackgroundColor:CGColorCreateGenericRGB(1.0, 0.0, 0.0, 1.0)]; [self.layer addSublayer:layer]; [layer display]; I put this in the - (void)drawRect:(NSRect)rect method

In Objective-C (OS X), is the “global display” coordinate space used by Quartz Display Services the same as Cocoa's “screen” coordinate space?

[亡魂溺海] 提交于 2019-12-03 05:59:30
I'm attempting to create an image "loupe" for my application that can be used to inspect images at different magnification levels, and I have run into a bit of a road bump. I'm using Quartz to create a CGImageRef snapshot of a selected portion of the display my app's window is on. The problem is, the nomenclature used by all of the different OS X technologies has me really confused. The function I'm using is CGDisplayCreateImageForRect(CGDirectDisplayID display, CGRect rect) . The documentation states the CGRect rect parameter is the "rectangle, specified in display space , for the portion of

How do I create a CGRect from a CGPoint and CGSize?

久未见 提交于 2019-12-03 05:28:32
问题 I need to create a frame for a UIImageView from a varying collection of CGSize and CGPoint , both values will always be different depending on user's choices. So how can I make a CGRect form a CGPoint and a CGSize ? Thank you in advance. 回答1: Two different options for Objective-C: CGRect aRect = CGRectMake(aPoint.x, aPoint.y, aSize.width, aSize.height); CGRect aRect = { aPoint, aSize }; Swift 3: let aRect = CGRect(origin: aPoint, size: aSize) 回答2: Building on the most excellent answer from

GLPaint save image

时光总嘲笑我的痴心妄想 提交于 2019-12-03 05:23:46
问题 I'm trying to develop a complex painting application on the iPhone. I'm currently drawing using Quartz (e.g. CGContext ...). Unfortunately the Quartz overhead is just too slow for the type of drawing I'm doing, and I'm porting to OpenGL calls using the GLPaint example as a reference point. Is there a way to get a UIImage/CGImage from the EAGLview class (the equivalent of Quartz's UIGraphicsGetImageFromCurrentImageContext )? Basically I need to save the pictures drawn by the GLPaint

Drawing animation

走远了吗. 提交于 2019-12-03 05:20:07
问题 I'm creating a simple app where when the user presses a button, a series of lines will be drawn on the screen and the user will be able to see these lines drawn in real time (almost like an animation). My code looks something like this (has been simplified): UIGraphicsBeginImageContext(CGSizeMake(300,300)); CGContextRef context = UIGraphicsGetCurrentContext(); for (int i = 0; i < 100; i++ ) { CGContextMoveToPoint(context, i, i); CGContextAddLineToPoint(context, i+20, i+20);

How to draw a shape on top of a UIImage while respecting the image's alpha mask

落花浮王杯 提交于 2019-12-03 03:58:44
问题 I need a UIImageView that can draw itself in color or b/w according to a flag: BOOL isGrey; I'm trying to do it by drawing a black rectangle on top of the original image with the Quartz blendmode set to Color. This works except it doesn't respect the image's alpha mask. See illustration: alt text http://img214.imageshack.us/img214/1407/converttogreyscaleillo.png Searching Google and SO, I found and tried several solutions but none respect the mask either. Here is the code that produces the

iOS: How do you measure the width and height of a string using Quartz?

≡放荡痞女 提交于 2019-12-03 03:15:42
问题 Before I ask my questions, this is from Apple's documentation re: how to determine the width of a string using Quartz: If text measurements are important to your application, it is possible to calculate them using Quartz 2D functions. However, you might first consider using ATSUI, whose strength is in text layout and measurement. ATSUI has several functions that obtain text metrics. Not only can you obtain after-layout text metrics, but in the rare cases you need them, you can obtain before