Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 763
Matrosov Oleksandr Avatar asked Feb 11 '23 22:02

Matrosov Oleksandr


1 Answers

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.

like image 64
Daniel Avatar answered Feb 24 '23 03:02

Daniel