开发者

Getting Large System Preview Image like in Finder

So, I am working on an app that displa开发者_JS百科ys some info about the current computer, and I want it to be quite Finder-like. When you do Get Info on your computer in Finder, there is a preview section with a large icon of your computer. I want to be able to get these in my code. For example, I have the Mid-2010 MacBook. Doing a bit of searching, it turned out that icon is present in /System/Library/CoreServices/CoreTypes.bundle/Contents/Resources/com.apple.macbook-unibody-plastic.icns

I am able to get the system model, and I suppose Finder does that and has some sort of mapping to map the system model to the correct image. Does anyone know where this sort of mapping is located, or how I could replicate this effect?


Very easy:

NSImage *computerIcon = [NSImage imageNamed:NSImageNameComputer];

The resulting image has multiple sizes (NSImageReps). Depending on where you draw it, the right size should be chosen automatically. To access a specific size (like the 512x512) version, you could do something like:

NSImageRep *largeRep = [computerIcon bestRepresentationForRect:NSMakeRect(0, 0, 512, 512) context:nil hints:nil];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜