osx - Loading retina images from a subdirectory -
i'm using nsdrawninepartimage()
draw stretchable control. since of course requires 9 separate images draw parts (plus extras drawn on that), have directory full of files top-left.png
, top-left@2x.png
. include directory in app bundle folder reference.
unfortunately, usual image-loading apis -[nsimage imagenamed:]
, -[nsbundle imageforresource:]
don't seem support subdirectories, if put slash in name. instead, i'm loading images method:
- (nsimage*)popoverimage:(nsstring*)name { nsurl * url = [[nsbundle bundleforclass:self.class] urlforresource:name withextension:@"png" subdirectory:@"popover"]; return [[nsimage alloc] initwithcontentsofurl:url]; }
this works fine normal displays, ignores 2x images retina displays. how can load retina images well? there better way loading 2 reps separately , combining them hand? i'd rather not use tiffs source files these resources, because use acorn image editor , last time checked, doesn't understand compound image formats well.
the simple answer use tiff's, concern misplaced. in xcode set project preference "combine high resolution artwork" , continue produce 2 png's acorn now. during build xcode combine 2 png's single tiff , store in bundle.
Comments
Post a Comment