static const CGRect screenRect = [[UIScreen mainScreen] bounds];
static const CGFloat screenWidth = screenRect.size.width;
static const CGFloat screenHeight = screenRect.size.height;
I understand that screen size is a runtime variable and not known at compile time. I've seen similar questions regarding arrays and other objects, but those don't directly pertain to this.
What is needed is a quick way to access the screen sizes, because thats how I'm doing all of the layout, and I don't want to redefine screenHeight
and screenWidth
in all my lazy loading property initializers, such as textFields and labels. I'm aware of self.view.frame.size
but I'm looking for a more elegant solution.
So how can I go about having screenHeight
and screenWidth
widely accessible in the code for my app?