[英]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.