Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to draw an UIImage or directly in -drawRect:?

People also ask

What is UIImage?

An object that manages image data in your app.

What is use of UIImageView?

Overview. Image views let you efficiently draw any image that can be specified using a UIImage object. For example, you can use the UIImageView class to display the contents of many standard image files, such as JPEG and PNG files.


Call [img drawInRect:rect];.


BTW, you shouldn't load the image file in the drawRect method. Because the method is called whenever the view is required to update. Therefore, it (of course, loading procedure) may be called many many times during running. (Furthermore, OS2.x's imageNamed method has a bug -- not cached the image and leaked it.)

Therefore, you'd better to load the file in the initialization method, not in the drawRect.