-1

I am new to ios dev, and wondering what are best practices to manage visual assets that are integrated into the app in xcode. Do people have copies of each UI for each form factor, including orientation? resize programmatically? other ways? I am doing all my UI programmatically but no idea whats the best way to manage the assets, meaning, the actual PNG files.

moshikafya
  • 3,190
  • 5
  • 22
  • 27

1 Answers1

1

Whenever possible, I like to use resizable images. UIImage has a method resizableImageWithCapInsets:resizingMode: which takes a condensed image and stretches the center row, column, or single pixel as wide or as tall as you want it. This is how iOS creates a lot of its buttons, including the buttons seen in action sheets.

If you need to have separate assets for orientations, I would recommend using suffixes on the file name. So you might have Button-Portrait.png and Button-Landscape.png. You could also add a category on UIImage that takes an image name, detects the current orientation, and gets the actual image file.

Community
  • 1
  • 1
FeifanZ
  • 16,250
  • 7
  • 45
  • 84
  • thats only for iOS6...what did people do before? – moshikafya Nov 14 '12 at 01:50
  • `stretchableImageWithLeftCapWidth:topCapHeight:` was the old method, although it's now deprecated. – FeifanZ Nov 14 '12 at 01:50
  • do you keep images for each resolution (pre-retina, retina, iphone 5) and for both orientations for each UI element? – moshikafya Nov 14 '12 at 02:12
  • You'd want a non-retina, retina (don't need anything special for iPhone 5 unless you're using full screen assets), and for both assets as necessary. – FeifanZ Nov 14 '12 at 02:23
  • sorry for too many questions, but what about orientations? do you have assets for non-retina and retina also for both orientation (assuming you need for your app)? – moshikafya Nov 14 '12 at 02:26
  • Yes, unless you're using resizable images, in which case you'd still want a retina and non-retina version, but you don't have to worry about orientation. – FeifanZ Nov 14 '12 at 21:19