2

我对使用 Objective C 绘制图像非常陌生。我在 iPhone 开发中完成了图像绘制,但现在我想在 Mac 上这样做。简而言之,下面的 iPhone 代码对应的 Mac 是什么?

- (void) drawRect: (CGRect) rect
{
    [super drawRect:rect];

    UIImage *anotherimage = [UIImage imageNamed:@"alert.png"];
    CGPoint imagepoint = CGPointMake(10,0);
    [anotherimage drawAtPoint:imagepoint];

}
4

1 回答 1

3

假设您不想要任何图像透明度和合成效果,这应该可以工作。

-(void)drawRect:(NSRect)dirtyRect
{
    [super drawRect:dirtyRect];
    NSImage *anotherImage = [NSImage imageNamed:@"alert.png"];
    [anotherImage drawAtPoint:NSMakePoint(10,0) fromRect:rectToDrawImage operation:NSCompositeCopy fraction:1.0];
}
于 2013-11-03T23:46:40.400 回答