iOS 开发实用技术导航
NSHipster 中文版
› http://nshipster.cn/
cocos2d 开源 2D 游戏引擎
› http://www.cocos2d-iphone.org/
CocoaPods
› http://cocoapods.org/
Google Analytics for Mobile 统计解决方案
› http://code.google.com/mobile/analytics/
WWDC
› https://developer.apple.com/wwdc/
Design Guides and Resources
› https://developer.apple.com/design/
Transcripts of WWDC sessions
› http://asciiwwdc.com
Cocoa with Love
› http://cocoawithlove.com/
Cocoa Dev Central
› http://cocoadevcentral.com/
NSHipster
› http://nshipster.com/
Style Guides
› Google Objective-C Style Guide
› NYTimes Objective-C Style Guide
Useful Tools and Services
› Charles Web Debugging Proxy
› Smore
winiex
V2EX  ›  iDev

iOS 中的 UIView 以及 CALayer 的定位机制

  •  
  •   winiex · Nov 11, 2014 · 3798 views
    This topic created in 4344 days ago, the information mentioned may be changed or developed.
    UIView 以及 CALayer 都有一套自己的定位机制,当你要自己绘制自定义控件的时候是非常重要的。UIView 有 frame、bounds、center,CALayer 有 frame、bounds、anchorPoint、position,这些属性又各有用处,相互之间也有关联。

    我看了介绍 UIView 和 Core Animation 的相关官方文档[1][2]和博客文章[3]后对这些概念有一个大体的认识(依然比较模糊),但是对于它们相互之间的影响关系以及更深层次的应用有些不解。

    特别是,CALayer 的相关属性和 UIView 的相关属性之间的联系是怎样的?UIView 作为自己的 CALayer 的 delegate,是怎么去代理自己的 CALayer 对象的?

    麻烦前辈们根据自己的经验指教一下啊,多谢 :)。

    [1] https://developer.apple.com/library/ios/documentation/WindowsViews/Conceptual/ViewPG_iPhoneOS/Introduction/Introduction.html
    [2] https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreAnimation_guide/Introduction/Introduction.html
    [3] http://wonderffee.github.io/blog/2013/10/13/understand-anchorpoint-and-position/
    2 replies  •  2015-01-13 12:52:22 +08:00
    winiex
        2
    winiex  
    OP
       Jan 13, 2015
    研究了一段时间,自己写了篇总结,希望对大家有帮助 :)

    http://bachiscoding.com/blog/2014/11/11/relationship-between-anchor-point-and-position-property-of-calayer/
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2288 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 37ms · UTC 07:15 · PVG 15:15 · LAX 00:15 · JFK 03:15
    ♥ Do have faith in what you're doing.