开发者

High-resolution icon for file in Mac OS X?

开发者 https://www.devze.com 2022-12-19 03:38 出处:网络
I am looking for a method exactly like -[NSWorkspace iconForFile:] but which returns the icon in a higher resolution if possible.In particular, I have an app which makes use of QuickLook to display pr

I am looking for a method exactly like -[NSWorkspace iconForFile:] but which returns the icon in a higher resolution if possible. In particular, I have an app which makes use of QuickLook to display previews of fil开发者_JS百科es, and I'd like it to fall back to the file icon if no quick look plugin is available. Using the iconForFile: method, however, yields a small 32x32 icon. Is there a better method around? One that returns an NSImage or CGImageRef is preferred, but less accessible methods might be fine too.


The returned image of -[NSWorkspace iconForFile:] contains multiple representations, including higher resolution ones.

If you try drawing it at 512x512 it will automatically pick the appropriate representation.


Here is the way to make icon bigger:

NSImage * icon = [NSWorkspace iconForFile:yourPath];
[icon setSize:NSMakeSize(64,64)];

Thats it. Good luck!

0

精彩评论

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

关注公众号