zoukankan      html  css  js  c++  java
  • Core Animation Layer(22)

    Notice in Figure 22.2 that each view has a layer and each view is its layer’s delegate. We’ll come back to the delegate relationship later in the chapter.
    So what’s the reason behind having views
    and layers? Remember that UIView is a subclass of UIResponder. A view is really an abstraction of a visible object that can be interacted with on the screen, wrapped into a tidy class. A layer, on the other hand, is all about the drawing

    Notice that layers interpret their size and position differently than views do. With a UIView, we typically define the frame of the view to establish its size and position. The origin of the frame rectangle is the upper-left corner of the view, and the size stretches right and down from the origin.

    For a CALayer, instead of defining a frame, you set the bounds and position properties of the layer. The default setting for position is the center of the layer in its superlayer. (The anchorPoint property determines where the position lies inside the layer’s bounds, and its default value is (0.5, 0.5), otherwise known as the center.) Therefore, if you change the size of the layer but leave the position constant, the layer will remain centered on the same point.

    Even though a layer doesn’t have a frame property, you can still get and set its “frame” by sending it the messages frame and setFrame:. When a layer is sent the message frame, it computes a rectangle from its position and bounds properties. Similarly, when sending a layer the message setFrame:, it does some math and then sets the bounds and position properties accordingly.

    However, it is better to think of layers in terms of their position and bounds properties. The mental math needed to animate a layer is much simpler if you stick to setting the bounds and position properties directly. 

    blog

    http://www.raywenderlich.com/2502/calayers-tutorial-for-ios-introduction-to-calayers-tutorial 

  • 相关阅读:
    Cocos2Dx for XNA类解析(1): CCApplication
    struts2动态调用action的方法
    python导出依赖包
    python 字符串split()方法
    struts2使用通配符调用action
    python3重新编译
    Jquery中html()、text()、val()的使用和区别
    Javascript写在<body>和<head>中的区别
    设计模式Design Pattern(2)单例模式
    设计模式Design Pattern(1)简介
  • 原文地址:https://www.cnblogs.com/zhangjl/p/3668922.html
Copyright © 2011-2022 走看看