0

Vertically, my views:

Safe Area <- 40 -> Label

So in Interface Builder, iPhone 8, the Label has a Y coordinate of 60. Because of the 40 top constraint, but also the safe area has a height of 20

At runtime, I also see the label has the Y coordinate of 60

However, when I set a breakpoint in viewDidLoad(), it looks like that safe area isn't factored in y et, because the Label has a Y coordinate of 40

I have tried calling view.layoutSubviews(), and the Label still doesn't move until some time after viewDidLoad().

Is there any way to get the final Y coordinate (60) in my viewDidLoad()?

Akash Bhardwaj
  • 308
  • 2
  • 11
A O
  • 5,516
  • 3
  • 33
  • 68
  • `viewDidLoad`, as its name suggests, is when the views are loaded, not when they are laid out. They are laid out when `viewDidLayoutSubviews` is called. Is there any reason why you want the label to be laid out correctly specifically in `viewDidLoad`? – Sweeper May 11 '19 at 06:58

1 Answers1

0

Following-up on this, the final positions of my views were set before viewDidAppear, so that's where I ended up doing my frame computations

A O
  • 5,516
  • 3
  • 33
  • 68