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

前端 未结 2 585
情深已故
情深已故 2020-12-05 02:13

I have an UIImage which I want to draw on a UIView. But instead of creating an UIImageView and adding this as a subview, I want to ove

相关标签:
2条回答
  • 2020-12-05 02:19

    Call [img drawInRect:rect];.

    0 讨论(0)
  • 2020-12-05 02:20

    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.

    0 讨论(0)
提交回复
热议问题