Reputation: 41510
If you have the option to use core graphics or stretchable UIImage (assuming either way will work) to render your graphics in your iOS app, which will you use? What's the pros and cons doing it one way over the other?
Upvotes: 0
Views: 237
Reputation: 29946
UIImage
is quite likley using CoreGraphics (or maybe CoreAnimation) under the covers. You can either do the same work yourself, and maybe make a mistake, or you can leverage UIKit
's well-tested implementation. The other potential advantage is that there may be non-obvious performance advantages gleaned by using UIImage
. For instance, unlike on OS X, you can't manually create a CGContext
backed by an IOSurface
on iOS, but perhaps UIImage
could do that by virtue of being able to use private API to do its job. (The truly curious can investigate what UIKit is doing using the debugger or dtrace
.)
In short, use the highest level of abstraction that gets the job done (UIKit being a higher level API than CoreGraphics.) If UIImage
's stretched drawing routines get the job done for you, I can think of few reasons not to use them. One potential reason I can envision for not using UIImage
routines might be if you were developing a cross-platform library intended to run on both OS X and iOS.
PS: "Being unacceptably slow in a way that doing it in a lower level API wouldn't be" would count in my mind as "not getting the job done," but you can't know that without trying both ways and measuring.
Upvotes: 1