V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
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 · 2014-11-11 15:20:19 +08:00 · 2984 次点击
    这是一个创建于 3451 天前的主题,其中的信息可能已经有所发展或是发生改变。
    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 条回复    2015-01-13 12:52:22 +08:00
    walkingway
        1
    walkingway  
       2014-11-16 22:56:16 +08:00   ❤️ 1
    winiex
        2
    winiex  
    OP
       2015-01-13 12:52:22 +08:00
    研究了一段时间,自己写了篇总结,希望对大家有帮助 :)

    http://bachiscoding.com/blog/2014/11/11/relationship-between-anchor-point-and-position-property-of-calayer/
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   3499 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 04:53 · PVG 12:53 · LAX 21:53 · JFK 00:53
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.