视图控制器从它的_view
实例变量中引用它的视图。
视图不直接存储其框架。它只是返回其层的“框架”。
视图从其_layer
实例变量中引用其层。
该图层也不存储帧。bounds
它根据、position
、anchorPoint
和计算其框架transform
。大小是 的一部分bounds
。
该层不直接将其边界存储在实例变量中。相反,它的layer
实例变量引用了一个私有 C++ 类的实例,CA::Layer
. 此类的成员布局未记录。
换句话说,你可以去self->_view->_layer->layer
到CA::Layer
实例,但是你被卡住了,因为你不知道在哪里CA::Layer
找到边界。
因此,尝试使用观察点来检测视图大小的变化是相当困难的。
在 .上放置断点更容易-[CALayer setBounds:]
。
在模拟器上
切记在断点条件中使用层地址,而不是视图地址。
(lldb) po self.view
(UIView *) $1 = 0x0a034690 <UIView: 0xa034690; frame = (0 20; 768 1004); autoresize = W+H; layer = <CALayer: 0xa034780>>
(lldb) break set -F '-[CALayer setBounds:]' -c '((int*)$esp)[1] == 0xa034780'
Breakpoint created: 2: name = '-[CALayer setBounds:]', locations = 1, resolved = 1
当断点被命中时,CALayer
实例被 引用((int *)$esp)[1]
,新的边界是*(CGRect *)($esp+12)
:
(lldb) po ((int*)$esp)[1]
(int) $8 = 167987072 <CALayer:0xa034780; position = CGPoint (384 480); bounds = CGRect (0 0; 768 1004); delegate = <UIView: 0xa034690; frame = (0 -22; 768 1004); autoresize = W+H; layer = <CALayer: 0xa034780>>; sublayers = (<CALayer: 0xa033010>); backgroundColor = <CGColor 0xa034960> [<CGColorSpace 0xa02b3b0> (kCGColorSpaceDeviceRGB)] ( 1 1 1 1 )>
(lldb) p *(CGRect*)($esp+12)
(CGRect) $9 = origin=(x=0, y=0) size=(width=768, height=960)
(lldb) finish
(lldb) po 0xa034780
(int) $10 = 167987072 <CALayer:0xa034780; position = CGPoint (384 480); bounds = CGRect (0 0; 768 960); delegate = <UIView: 0xa034690; frame = (0 0; 768 960); autoresize = W+H; layer = <CALayer: 0xa034780>>; sublayers = (<CALayer: 0xa033010>); backgroundColor = <CGColor 0xa034960> [<CGColorSpace 0xa02b3b0> (kCGColorSpaceDeviceRGB)] ( 1 1 1 1 )>
在设备上
切记在断点条件中使用层地址,而不是视图地址。
(lldb) po self.view
(UIView *) $0 = 0x1f031a10 <UIView: 0x1f031a10; frame = (0 20; 768 1004); autoresize = W+H; layer = <CALayer: 0x1f031b00>>
(lldb) break set -F '-[CALayer setBounds:]' -c '$r0 == 0x1f031b00'
Breakpoint created: 2: name = '-[CALayer setBounds:]', locations = 1, resolved = 1
当断点被命中时,CALayer
实例被 引用$r0
,新的 X 原点在$r2
,新的 Y 原点在$r3
,新的大小是*(CGSize *)$sp
:
(lldb) po $r0
(unsigned int) $7 = 520297216 <CALayer:0x1f031b00; position = CGPoint (384 480); bounds = CGRect (0 0; 768 1004); delegate = <UIView: 0x1f031a10; frame = (0 -22; 768 1004); autoresize = W+H; layer = <CALayer: 0x1f031b00>>; sublayers = (<CALayer: 0x1f030840>); backgroundColor = <CGColor 0x1f031ce0> [<CGColorSpace 0x1e530ad0> (kCGColorSpaceDeviceRGB)] ( 1 1 1 1 )>
(lldb) p/f $r2
(unsigned int) $14 = 0
(lldb) p/f $r3
(unsigned int) $15 = 0
(lldb) p *(CGSize *)$sp
(CGSize) $16 = (width=768, height=960)
(lldb) finish
(lldb) po 0x1f031b00
(int) $17 = 520297216 <CALayer:0x1f031b00; position = CGPoint (384 480); bounds = CGRect (0 0; 768 960); delegate = <UIView: 0x1f031a10; frame = (0 0; 768 960); autoresize = W+H; layer = <CALayer: 0x1f031b00>>; sublayers = (<CALayer: 0x1f030840>); backgroundColor = <CGColor 0x1f031ce0> [<CGColorSpace 0x1e530ad0> (kCGColorSpaceDeviceRGB)] ( 1 1 1 1 )>