I am making a basic Minesweeper app for practice / fun in swift. I want to make it so the size of the board (10 tiles wide) adapts to any iOS screen.
To do this I\'m se
When you are using auto-layout, the subviews are laid out after the viewDidLayoutSubviews
function. Therefore, if you call tileContainer.frame.size
before that, such as in viewDidLoad
, it will always be 600 by 600 (which is the default size in storyboard).
viewDidLayoutSubviews: Called to notify the view controller that its view has just laid out its subviews. reference
override func viewDidLayoutSubviews() {
super.viewDidLayoutSubviews()
print(tileContainer.frame.size); // This is actual size you are looking for
}