Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Drawing In Code

Drawing In Code

Drawing graphics in code for you iPhone and iPad interfaces

David Keegan

May 08, 2013
Tweet

More Decks by David Keegan

Other Decks in Programming

Transcript

  1. Core Graphics The Core Graphics framework is a C- based

    API that is based on the Quartz advanced drawing engine.
  2. What can it do? •Draw circles, rectangles, rounded rectangle, bezier

    paths, and text •Draw gradients, solid colors, and patterns •Blending modes: screen, multiply... •Read and write PDFs
  3. Reduced App Size •A full screen retina iPad image is

    about 4Mb, plus the non-retina version. •Every image you do not need to include will reduce the size of your app bundle. 50 Mb download limit over cellular
  4. Designers & Developers •Designers: Photoshop is not enough, might need

    to learn new tools like PaintCode, might even have to touch some code... •Developers: Longer setup time, [UIImage imageName:] is easier to use.
  5. Speed We can solve this issue with caching. That way

    we only pay for the render time once.
  6. NSCache •Render the graphics to an image, cache that image

    and reuse it. •NSCache is great for this because it will automatically dump content if the app receives a memory warning. •NSCache is what [UIImage imageNamed:] uses under the hood.
  7. File Cache Writing the cached image to disk is also

    a good option. This way you only have to render it once instead of each time it is not in memory.
  8. PaintCode PaintCode is a great visual editor for creating and

    styling vector shapes that outputs Objective-C drawing code. In the latest version of PaintCode they even added a feature to import Photoshop files. http://www.paintcodeapp.com
  9. Conclusion •Drawing in code is an awesome way to keep

    your app sizes small and build flexible interfaces that can change to fit any device. •Think about the tradeoffs when deciding to use an image or draw something in code. If it is already done in Photoshop maybe just use that. If it needs to scale or the colors will change maybe remake it in code.