Set up a picture to display
mylayer.contents=(ID)[UIImage imagenamed:@ "Me"]. Cgimage;
Here is the Cgimage property of UIImage, which is a cgimageref type of data.
1.CGColorRef and CGIMAGEREF data types
1. Brief description
Calayer is defined in the Quartzcore framework; cgimageref, cgcolorref two data types are defined in the Coregraphics framework; Uicolor, uiimage are defined in the Uikit framework.
Second, the Quartzcore framework and the Coregraphics framework are available across platforms and can be used on both iOS and Mac OS x, but Uikit can only be used in iOS
Therefore, in order to ensure portability, quartzcore can not use UIImage, Uicolor, can only use Cgimageref, Cgcolorref
However, in many cases, the Coregraphics object can be obtained by Uikit the specific method of the object, such as UIImage Cgimage method can return a cgimageref.
Selection of 2.UIView and Calayer
You can see that the previous 2 effects can be implemented not only by adding layers, but also by adding uiview. The layer that displays the picture can be implemented with a uiimageview. Since Calayer and UIView all can achieve the same display effect, then who should choose who is good?
In fact, compared with the Calayer,uiview more than one event processing function. In other words, Calayer cannot handle user touch events, while UIView can.
Therefore, in the process of selection, you need to take into account the actual situation, if the displayed things need to interact with the user, with UIView, if you do not need to interact with the user, with UIView or Calayer can
Of course, the performance of Calayer is higher because it is less capable of event handling and more lightweight
Calayer Use note