1

I've found a program for converting SVG images directly into code. Sounds like an epic solution for iOS application size problems but here occurs some obstacles. Drawing complex images result into 4k+ lines of hardcore code. Its about 100 kB pure file size that almost equals to initial png image size.

So the question - is there any point(total app size gain) of drawing such kind of images from code or better include em in project as normal pngs? Whats the ration between code size and binary size? Or how could I calculate it?

Mehdzor
  • 789
  • 4
  • 9
  • 23
  • 1
    I think performance consideration is more important. drawRect uses software code for drawing which is less efficient as compared to UIKIt Image which is processed by GPU. – Kunal Balani Dec 09 '13 at 19:59
  • Kunal, as I tested - drawing from code is faster than pure image insertion. First of all you need to fetch image from bundle. Even so in business applications there is no rush for fast render - 0.02 seconds or 0.002 - is not too important. – Mehdzor Dec 09 '13 at 20:06
  • I don't know how did you managed to get that conclusion. You can't just compare two functions and draw conclusions based on that. Your drawRect runs on main thread you want it to be efficient. http://stackoverflow.com/questions/14659563/to-drawrect-or-not-to-drawrect-when-should-one-use-drawrect-core-graphics-vs-su – Kunal Balani Dec 09 '13 at 20:11
  • btw , use instruments and compare numbers in terms of fps not absolute seconds. Use instruments to measure it using core animation tool. – Kunal Balani Dec 09 '13 at 20:14
  • Sounds interesting. Thanks for good information. – Mehdzor Dec 09 '13 at 20:20
  • As I found - Bezier Path which is used for image drawing is a part of UIKit. Does it affect performance? – Mehdzor Dec 09 '13 at 20:42

1 Answers1

0

After times of research, I've found that UIBezierPath solves my problem pretty nice. Yes, UIBezierPath is just a wrap for CoreGraphics that is based on CPU but as Apple recommends - use highest level of abstraction for your purposes and let system do it job.

Performance for drawing vector images using UIBezierPath is high enough for any 2D interface element. As I've tested - speed factor for retina display even for hardest images was about 45-50 fps that is more than enough for primitive UI animations.

So the verdict is - drawing your interface using code saves memory and nerves.

Mehdzor
  • 789
  • 4
  • 9
  • 23