viewWillLayoutSubviews

1.切换横竖屏时,让一个控件的位置改变,就会调用这个方法,viewWillLayoutSubviews.

2.官门文档解释

When a view'€™s bounds change, the view adjusts the position of its subviews. Your view controller can override this method to make changes before the view lays out its subviews. The default implementation of this method does nothing.

当一个视图的€™的边界变化,在视图调整其子视图的位置。你的视图控制器可以重写此方法以在视图布局它的子视图更改。该方法的默认实现不执行任何操作。

You may override this method in a subclass in order to add constraints to the view or its subviews. If you override this method, your implementation must invoke super’s implementation.

你可能在为一类约束添加到视图或它的子视图重写这个方法。如果你重写这个方法,您的实现必须调用超的实现。

3.例子

To use a top layout guide without using constraints, obtain the guide’€™s position relative to the top bound of the containing view. In the case of using a view controller subclass, obtain the numbers you need as follows:

使用上面的布局指南没有使用限制,获得指导的€™的位置相对于顶部的含视图绑定。在使用一个视图控制器类的情况下,获得你需要的号码如下:
- (void) viewDidLayoutSubviews {
CGRect viewBounds = self.view.bounds;
CGFloat topBarOffset = self.topLayoutGuide.length;
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值