quartz-2d

iOS rotate UIImage using Quartz

孤街醉人 提交于 2019-12-12 00:32:04
问题 I have a UIView subclass with custom - (void)drawRect:(CGRect)rect I want to draw an UIImage at position 50,50 and have it rotated by 20 degrees. I tried the following code: CGContextRef context = UIGraphicsGetCurrentContext(); CGContextSaveGState(context); CGContextRotateCTM (context, degreesToRad(20)); [image drawAtPoint:CGPointMake(50, 50)]; CGContextRestoreGState(context); It rotates the image correctly, but it is not at 50,50... How can I rotate an UIImage while maintaining the correct

How to draw a drop shadow AND gradient with quartz2d?

我与影子孤独终老i 提交于 2019-12-11 06:26:35
问题 I've a custom shape drawing using coregraphics and i want to add a drop shadow and a gradient to it also. I've been trying and searching a lot of informations on how to combine and do this, but i can't get it to work. I'm able to draw only one either. Anyone doing this already or know how to do this? Thank you. 回答1: Quartz only applies shadows to fills and strokes. Drawing a gradient does not count as a fill. Fill with a solid color (to draw the shadow), then draw the gradient in the same

CGDisplayModeGetWidth/Height() sometimes returns pixels, sometimes points

╄→гoц情女王★ 提交于 2019-12-11 06:22:32
问题 According to Apple, both CGDisplayModeGetWidth() and CGDisplayModeGetHeight() should return points instead of pixels starting in macOS 10.8. But Apple's word on those APIs isn't consistent because here they say that the functions return pixels and not points. This confusion is also reflected in practice because both functions only seem to return points sometimes, not all the time. Sometimes they also return pixels. Consider this example: CGDirectDisplayID id = CGMainDisplayID(); CFArrayRef

Mac dev - Help getting started with 2d games

老子叫甜甜 提交于 2019-12-11 06:15:15
问题 I want to make some simple 2d games/clones (for Mac), but I have a few questions: Should I use Quartz 2d or OpenGL (I don't plan to try 3d anytime soon) There seems to be a lot of typedef'd things like CGFloat/GLfloat, which should I use? Should I use Objective-C for the game too (classes) or just C? (I assume I'll use Objective-C and Cocoa for window and views.) Is it fine to redraw the entire view each time? I don't really understand how the NSView's -drawRect dirtyRect parameter works, how

masking UIView based on CGRect

时间秒杀一切 提交于 2019-12-11 02:49:17
问题 Look at the image please : I have UIView and CGRect. I have to check where CGRect overlays UIView and then set the mask on the area which is "opposed" to intersection. So it's blue part in the image. How to achieve that? I know there's CGContextClipToMask but I have no idea how to use that - could someone help me with example code? Is CGContextClipToMask good direction? Thanks! 回答1: You can assign mask layer to your UIView's layer. CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init]; view

iPhone: Clip user-supplied UIImage by a given CGPath

廉价感情. 提交于 2019-12-10 18:13:06
问题 In my iPhone application, I need to let user to clip user-supplied UIImage by given dynamically generated CGPath . All that is outside given (closed) CGPath should be clipped out, and the resulting image should be trimmed by path's bounding rectangle. Image should be clipped with soft border. That is, there should be a soft gradient in the alpha channel on the edge of clipping path, from transparent to opaque pixels. Is there any available solution to achieve described effect? The main

Copying the drawn contents of one UIView to another

梦想的初衷 提交于 2019-12-10 17:14:25
问题 I'd like to take a UITextView and allow the user to enter text into it and then trigger a copy of the contents onto a quartz bitmap context. Does anyone know how I can perform this copy action? Should I override the drawRect method and call [super drawRect] and then take the resulting context and copy it? If so, does anyone have any reference to sample code to copy from one context to another? Update: from reading the link in the answer below, I put together this much to attempt to copy my

Custom UIBarButtonItem with quartz

情到浓时终转凉″ 提交于 2019-12-10 16:07:08
问题 How can I draw a button with quartz that has exactly the same style as a UIBarButtonItem. The button should be able to show different colors. I downloaded the Three20 project, but this project is really complex, you'd need a lot of time to overlook the whole framework. I just want to draw a custom UIBarButtonItem. Thanks for help. 回答1: If you are using the Three20 library, I guess TTButton's "toolbarButton" style is what you want. TTButton is a sub-class of UIButton, but it allows you to

Best Practice for laying out images for printing in a WYSIWYG Mac app?

对着背影说爱祢 提交于 2019-12-10 12:00:05
问题 I'm in the concept phase of a Mac application that should let the user easily select and layout images for printing. It's a document-based app and a document can have multiple pages with lots of pictures in different sizes and rotations on it. The UI would kind of be like the UI of Pages.app. Those pictures can possibly be large hi-res images. The user should also be able to print them in the best quality that the images offer. I have re-watched some WWDC sessions about Quartz, 2D drawing

How to open and View PDF using Quartz 2d

我们两清 提交于 2019-12-10 11:56:15
问题 Hi I've been trying to achieve this with no success I'm trying to take the following code and view it using Quartz 2D - So I could later annotate using this: $ NSString *path = [[NSBundle mainBundle] pathForResource:@"01renalArtery" ofType:@"pdf"]; NSURL *url = [NSURL fileURLWithPath:path]; NSURLRequest *request = [NSURLRequest requestWithURL:url]; [pdfView loadRequest:request]; [pdfView setScalesPageToFit:YES]; $ I've been through the following sample code https://developer.apple.com/library