how to change UIKit UIImage:drawInRect method to AppKIt NSImage:drawInRect Method
- by user322111
Hi,
i'm porting an iphone app to Mac app,there i have to change all the UIKit related class to AppKit.
if you can help me on this really appreciate. is this the best way to do below part..
Iphone App--using UIKit
UIGraphicsPushContext(ctx);
[image drawInRect:rect];
UIGraphicsPopContext();
Mac Os--Using AppKit
[NSGraphicsContext saveGraphicsState];
NSGraphicsContext * nscg = [NSGraphicsContext graphicsContextWithGraphicsPort:ctx flipped:YES];
[NSGraphicsContext setCurrentContext:nscg];
NSRect rect = NSMakeRect(offset.x * scale, offset.y * scale, scale * size.width, scale * size.height);
[NSGraphicsContext restoreGraphicsState];
[image drawInRect:rect fromRect:NSMakeRect( 0, 0, [image size].width, [image size].height )
operation:NSCompositeClear
fraction:1.0];