Is there any performance or memory overhead using UIImage
or UILabel
or NSString
in Quartz2D
.
If there is no difference then why not use UIImage
, UILabel
etc.
Can any one send me the snippet how to draw image without using UIImage
.
Thanks in advance,
Regards.
please correct me if you see any stupid mistake I am new to this, trying to learn it.
A label draws a string. You can't have a label without a string; if you did, what would it draw?
Last I checked, UILabel uses UIWebView internally, so you could indeed make a more efficient version. One way would be to use Core Text; the other would be to use a CATextLayer.
As for UIImage, technically yes; a UIImage wraps a CGImage, so cutting out the UIImage would save some memory. However, 99% of the memory used by an image is for the image itself, its pixels; those are contained within the CGImage, and the UIImage is tiny compared to it. You have better things to spend your time cutting.
Rather than guessing and/or relying on generalities for your optimizations, use Instruments to find out exactly what your application is spending its memory on. Once you know with hard evidence where all your memory is going, you'll know where you can look for savings.
Wrappers generally won't increase memory usage much; objects are small, so you'll only pay a lot for them if you create a lot of them. Look instead to shortening their lifetimes; don't hold onto objects (in caches, collection objects, or directly in instance variables/properties) any longer than you need to.