我正在使用它来组合 2 个 NSImages :
newImage = [[NSImage alloc] initWithSize:NSMakeSize(size1.width,
size1.height + size2.height)];
[newImage lockFocus];
[firimage drawAtPoint:NSMakePoint(0, 0)
fromRect:NSMakeRect(0, 0, size1.width, size1.height)
operation:NSCompositeSourceOver
fraction:1.0];
[secimage drawAtPoint:NSMakePoint(0, size1.height)
fromRect:NSMakeRect(0, 0, size2.width, size2.height)
operation:NSCompositeSourceOver
fraction:1.0];
[newImage unlockFocus];
它会生成正确尺寸的图像(2 100x63 图像会生成 100x126 图像),但是两个单独的图像绘制得太小,因此生成的图像大部分是空白的:
以下是原始图像: