我將一個iphone應用程序移植到Mac應用程序,我必須將所有UIKit相關的類更改爲AppKit。 如果你能幫助我,這真的很感謝。這是做下面的部分最好的辦法..如何更改UIKit UIImage:drawInRect方法到AppKIt NSImage:drawInRect方法
iPhone應用程序 - >使用UIKit的
UIGraphicsPushContext(ctx);
[image drawInRect:rect];
UIGraphicsPopContext();
MAC OS - 使用了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];