我正在将一个iPhone应用移植到Mac应用程序,因此我需要将所有与UIKit相关的类更改为AppKit。如果您能帮助我,我会非常感激。以下是最好的方法吗?
iPhone应用程序-->使用UIKit
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];
-[NSGraphicsContext save|restoreGraphicsState]
确实会推送/弹出这些消息的接收者的图形状态。然而,同名的 _类_方法+[NSGraphicsContext save|restoreGraphicsState]
却会推送/弹出上下文。 - Martin Winter