Today Bo Master has a content to draw the demand, encountered some difficulties, here and we share, hope to progress together.
Today share with you the difference between Calayer and UIView:
1.UIKit uses Uiresponder as the response object to respond to and process events passed by the system. UIApplication, Uiviewcontroller, UIView, and all Uikit classes derived from UIView, including UIWindow, inherit from the Uiresponder class directly or indirectly.
The interface that handles various events and event passing is defined in Uiresponder, and Calayer directly inherits NSObject, and there is no corresponding interface for handling events, the most obvious difference being that view can accept and handle events, and Layer can not
2. A frame of a layer is determined by its anchorpoint,position,bounds, and transform, and a view frame is simply a frame that returns to the layer, the same view as the cent Er and bounds are also some properties that return Layer.
When the view is displayed, the Calayerdelegate,view of the UIView as a Layer is drawn by the internal Calayer
3. Inside each UIView is a calayer that provides the drawing and display of the content behind it, and the UIView dimension style is provided by the inner Layer. Both have a tree-like hierarchy, and inside the layer there is a subviews inside the sublayers,view. But the layer is a anchorpoint more than the View.
The layer is maintained within the three-point layer tree, which is the Presentlayer tree (the Modelayer tree), the render tree, and in the animation of iOS, we modify the properties of the animation, which is actually The Presentlayer property value of the Layer, and the final display on the interface is actually the Modellayer that provides the view
4.CALayer is the default modification property to support implicit animation, when animating the layer of UIView, the View as the layer of the proxy, layer through Actionforlayer:forkey: to the View request the corresponding action (animation behavior ), for each UIView there is a layer, which is called the Rootlayer, rather than the root layer of the View, which is referred to as non-rootlayer. Our property modification to UIView does not produce the default animation at all times, and the default animation time default value is 0.25s when the individual layer property is modified directly.
5. Share with you a little bit of uiview conversion uiimage.
+ (uiimage*) Imagewithuiview: (uiview*) view{ uigraphicsbeginimagecontext (view.bounds.size); Cgcontextref Currnetcontext = Uigraphicsgetcurrentcontext (); [View.layer Renderincontext:currnetcontext]; uiimage* image = Uigraphicsgetimagefromcurrentimagecontext (); Uigraphicsendimagecontext (); return image;
iOS development diary 12-calayer and UIView