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 

  • 相关阅读:
    数据库索引的作用和长处缺点
    iOS安全攻防(三):使用Reveal分析他人app
    SVN server的搭建
    腾讯2014年实习生招聘笔试面试经历
    JAVA数组的定义及用法
    一年成为Emacs高手(像神一样使用编辑器)
    给想上MIT的牛学生说几句
    四个好看的CSS样式表格
    dede 留言簿 多个
    破解中国电信华为无线猫路由(HG522-C)自己主动拨号+不限电脑数+iTV
  • 原文地址:https://www.cnblogs.com/zhangjl/p/3668922.html
Copyright © 2011-2022 走看看