[英]Drawing text onto an NSImage in a loop - but how do I clear the cache?
[英]How do I draw a NSImage onto a NSView?
对于使用Objective C绘制图像,我是一个新手。我已经在iPhone开发中完成了图像绘制,但是现在我想在Mac上绘制图像。 简而言之,Mac相当于下面的iPhone代码?
- (void) drawRect: (CGRect) rect
{
[super drawRect:rect];
UIImage *anotherimage = [UIImage imageNamed:@"alert.png"];
CGPoint imagepoint = CGPointMake(10,0);
[anotherimage drawAtPoint:imagepoint];
}
假设您不希望任何图像透明度和构图效果,这应该可以工作。
-(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];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.