简体   繁体   中英

Autolayout detect when UIView got the frame

I have UIView that has auto layout constraints. I create it with frame CGRectZero . So I don't the real size. It will depend on superview.

But I want to know when my view get a frame that I can use for my calculation.

So you shouldn't really need to know anything about the frame. Although if you did need to know, you could just implement -layoutSubviews in your view, or -viewDidLayoutSubviews at the view controller level.

Here after calling super the frames should be set to what AutoLayout resolved them to be.

Also good practise to take on board is #7 of the following post: Forget frame .

I also highly recommend reading about the AutoLayout process here .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM