Please tell me how to avoid writing the following code on Objective-c each time.
CGSize sc=[[UISscreen mainScreen] bounds].size;
When I get the screen size of the terminal and do the layout, I write it down every time, but where should I declare it?
Thank you for your cooperation.ios xcode objective-c
For screen size-dependent codes, I believe that writing the auto-layout will reduce the number of actual pixels in the screen size, but I will answer on the premise that it is separate from the auto-layout.
How about creating a subclass of
UIApplication and defining a read-only property called
screenSize and running screenSize at
The sample code is as follows
Application Name .m
To take advantage of this, add an item to
principal class, and write the Application Name in the right column.
You can also use the
screenSize source file you want to browse to
screenSize is required.
You can then view the
screenSize obtained when starting the application.
After all, it's troublesome, so I don't think it's that different every time I write it, but I hope it'll be helpful if the variable I want to use again (
readwrite) and constant (
© 2023 OneMinuteCode. All rights reserved.