Reputation: 47
How do I get the actual view size? Right now I am getting it from gameView.frame.size
. It does give me the right values that I set, but it doesn't give me the actual size.
For example, in my storyboard I have an iPhone 11 and I draw a frame of width:375
and height:375
with constraints.
And now I simulate an iPad and the frame indeed does have the right constraints, but it is still giving me back the values 375-375 but that isn't the actual size.
Upvotes: 1
Views: 1657
Reputation: 1784
You have a couple of options; based on your use case:
Get your frame by using:
DispatchQueue.main.async {
//print(self.view.frame)
}
get your updated frame values in viewDidAppear
get your updated frame values in viewDidLayoutSubviews
. But be careful this is called multiple times.
Upvotes: 1