In the morning, a series of pages about UIView and Calayer, either came up a row of code (to break the elegant atmosphere), or the problem is not (hello, what is you ' write what '), see I was in the rain fog, of course, also have Daniel hard writing excellent articles, Just recently small series is also learning "core animation", because the core animation operation of the object is not UIView, but the Calayer, and for the two that cut constantly the relationship between the confusion of the small make-up through this blog to sort out some superficial ideas.
-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Iarontalk Blog opens.
Perhaps happiness does not arrange the position, but succeeds must arrange the position.
-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Step 1: God creates all things in the world when everything is returned to his own place, "to wind, to the water, people immediately create human." Come to think, jobs created OC (open a joke, I know not he wrote OC), does not have the foresight to each part of the design of a complete, so, I thought originally UIView is Uiview,calayer is calayer. Then the question came, when the two-bit head, and when entangled together, how can not tear open it? This is to start with the "epoch-based" talk.
Step 2: uiapplication, Uiviewcontroller, UIView, and all Uikit classes derived from UIView (including UIWindow) are inherited directly or indirectly from the Uiresponder class.
Calayer directly inherits NSObject.
Thus see, UIView and Calayer This is not the same root, if you want to break the wrong pull their two, first to understand what they both.
Step 3:UIView, we are familiar with the extent of this is said to be more than just to repeat, simply introduce the next TA bar. (UIView defines a rectangular area on the screen and an interface for managing the content of the area.) At run time, a View object controls the rendering of the area and also controls the interaction of the content, so UIView has three basic functions, drawing and animation, managing the layout of the content, and controlling events . It is because UIView has these features that it can act as the view layer in MVC. )
Calayer, for Daniel Nature, extremely easy, just for small series such a fledgling little fart child but to painstaking research a. Not much nonsense, let's meet Calayer June. (Calayer is included in the Quartzcore framework, which is a cross-platform framework that can be used both in iOS and Mac OS X.) The essence of developing animations with core animation is to convert the contents of Calayer into bitmaps for hardware operations, and the importance of their presence is in content presentation and animation operations. )
After knowing the creator's meaning, let's savor the two-bit in detail.
Step 4:UIView can respond to events,Calayer = NO.
UIView inheritance and Uiresponder, which define interfaces for handling various events and event passing in Uiresponder, and Calayer inherit NSObject directly, and there is no corresponding interface for handling events.
Step 5:UIView can add sub-view, that is, Subview, its common properties are not backgroundcolor, frame, transform, bounds and so on.
Calayer also exist in the sub-parent class relationship, that is sublayer, in addition to some of UIView's general properties, Calayer also has a property called Anchorpoint, which uses the cgpoint structure, but the range is 0~ 1, which is set according to the proportions.
Step 6: by STEP3:
UIView focuses on the management of display content, andCalayer focuses on drawing content.
Step 7: in Apple's official document there is a passage about UIView and Calayer , which formally opens the chapters belonging to UIView and Calayer.
Displaying Layers in views
Core Animation doesn ' t provide a means for actually displaying layers in a window, they must is hosted by a view. When paired with a view, the view must provide event-handling for the underlying layers, while the layers provide disp Lay of the content.
The view system in IOS are built directly on top of Core Animation layers. Every instance of UIView automatically creates an instance of a Calayer class and sets it as the value of the view ' s layer Property. You can add sublayers to the view ' s layer as needed.
At this time, Calayer and UIView evolved into a kind of dependence, hair in the skin, blood to the flesh, spirit to the soul, the man's relationship to the kidney .
Instead of two systems, UIView relies on content provided with Calayer, Calayer relies on the container provided by UIView to display the content being drawn.
Step 8: The editor Caishuxueqian, stubbornly believes that the authority of the class is higher than the attribute in the class (purely patriarchal patriarchal ideology), but in reality, the two cannot be compared simply, but for UIView and Calayer, The editor is adamant that the attribute of the Calayer should always serve the uiview, loyal to it is not abandoned, Calayer have all Angelica belongs to UIView (that is, by the UIView to show).
Step 9: There are peers who think the two: UIView from Calayer, higher than Calayer, is calayer high-level implementation and encapsulation. All features of the UIView are derived from Calayer support. In the final analysis Calayer is the basis of all this, if no calayer,uiview itself will not exist, UIView is a special calayer implementation, adding the ability to respond to events.
(The above comprehensive view, the blogger is agreed, but in the spirit of contempt).
Due to the limited level of the editor, it is unavoidable to ask the various Daniel to criticize, put forward valuable suggestions.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
A different perspective on "UIView" and "Calayer"--the relationship between the soul and the kidney of the man