有这样一种层次关系,我希望根据 view1 的大小来改变 view2 的大小,但是在 view3 的 layoutSubviews 中无法知道 view1 的大小,也就不能写 view2.frame = view1.frame 了,我想知道怎么做?
layoutSubviews
view2.frame = view1.frame
认证0级讲师
You can define a global variable. The size of view1 is this global variable, and it is used directly in view2
Kvo the frame of view1. If you really can’t get the instance of view1, just set a tag for view1
Solution: 1. KVO monitors the frame change of view1 2. Use constraints
You can define a global variable. The size of view1 is this global variable, and it is used directly in view2
Kvo the frame of view1. If you really can’t get the instance of view1, just set a tag for view1
Solution:
1. KVO monitors the frame change of view1
2. Use constraints