A UIScreen object contains the bounding rectangle of the device’s entire screen. When setting up your application’s user interface, you should use the properties of this object to get the recommended frame rectangles for your application’s window.
Questions tagged [uiscreen]
153 questions
226
votes
14 answers
Detect Retina Display
Does iOS SDK provides an easy way to check if the currentDevice has an high-resolution display (retina) ?
The best way I've found to do it now is :
if ([[UIScreen mainScreen] respondsToSelector:@selector(scale)] == YES && [[UIScreen mainScreen]…

Pierre Valade
- 3,388
- 3
- 24
- 29
186
votes
18 answers
Is [UIScreen mainScreen].bounds.size becoming orientation-dependent in iOS8?
I ran the following code in both iOS 7 and iOS 8:
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
BOOL landscape = (orientation == UIInterfaceOrientationLandscapeLeft || orientation ==…

lwxted
- 2,419
- 2
- 16
- 22
91
votes
15 answers
How to get device width and height?
In Objective-C we can get device width and height by using following code :
CGRect sizeRect = [UIScreen mainScreen].applicationFrame
float width = sizeRect.size.width
float height = sizeRect.size.height
How can do this in with Swift ?

Divya Bhaloidiya
- 5,018
- 2
- 25
- 45
50
votes
12 answers
How to get screen size using code on iOS?
How to get the iPhone screen size to give calculation?

haisergeant
- 1,111
- 2
- 13
- 32
49
votes
2 answers
What is the difference between -nativeScale and -scale on UIScreen in iOS8+?
In sample logs posted in this question, the results are identical. Does anyone know if there is meant to be a logical difference between the two?
Even Apple's description is confusing. Here is the description of scale:
The natural scale factor…

Dev Kanchen
- 2,332
- 3
- 28
- 40
46
votes
6 answers
UIScreen MainScreen Bounds returning wrong size
So I created a new project with the latest version of XCode and tried to log the screen size of my app (to determine the device type for UI). I ran the following code from my iPhone 5:
NSLog(@"%f", [[UIScreen mainScreen] bounds].size.height);
This…

Liftoff
- 24,717
- 13
- 66
- 119
34
votes
6 answers
How can I detect whether a user has an iPhone 6 Plus in standard or zoomed mode?
How can I detect whether a user has an iPhone 6 Plus in standard or zoomed mode?
Is this possible?
I've tried [UIScreen mainScreen].scale and it reports 3.0 in both cases.

barfoon
- 27,481
- 26
- 92
- 138
23
votes
2 answers
Adjust the main screen brightness using Swift
I would like to adjust the iPhone's main screen brightness in code using Swift.
I know in Objective-C it can be done by:
[[UIScreen mainScreen] setBrightness:0.5];
How do I do this in Swift?

CircuitPro
- 401
- 1
- 3
- 7
23
votes
2 answers
How to get iOS device screen height and width
Possible Duplicate:
IPhone/IPad: How to get screen width programmatically?
How to get orientation-dependent height and width of the screen?
Accounting for the various iOS devices and orientations, what is the simplest approach to getting the…

colindunn
- 3,139
- 10
- 48
- 72
19
votes
4 answers
How to change brightness in iOS 5 app?
How would I program the ability to change brightness in-app? I know that its possible as I have seen at least three apps that can do it. This would be very useful for my app. I know that it's only possible in iOS 5 with the UIScreen Class, but I…

cory ginsberg
- 2,907
- 6
- 25
- 37
15
votes
7 answers
Capturing full screenshot with status bar in iOS programmatically
I am using this code to capture a screenshot and to save it to the photo album.
-(void)TakeScreenshotAndSaveToPhotoAlbum
{
UIWindow *window = [UIApplication sharedApplication].keyWindow;
if ([[UIScreen mainScreen]…

Umair Khan Jadoon
- 2,874
- 11
- 42
- 63
15
votes
4 answers
How to find PPI programmatically with precision
I am trying to find out PPI(Pixels Per Inch) in iOS.
I couldn't find any direct way to query this like we do for display size
UIScreen.mainScreen().bounds
There is a way to do it by multiplying scale with standard generic PPI for iPhone(163) or…

Durai Amuthan.H
- 31,670
- 10
- 160
- 241
12
votes
3 answers
Unable to restore brightness on application exit
I have a feature in my app (a metronome app for musicians) to dim the screen in order to save on battery life. To set the brightness, I am using:
[UIScreen mainScreen].brightness = 0.1;
I am saving the original brightness on app start up in…

TheTwoNotes
- 453
- 3
- 15
12
votes
2 answers
UIScreen bounds versus applicationFrame
Why do I see in some sample code from Apple (such as PhotoScroller) that I should do the following in loadView:
CGRect frame = [[UIScreen mainScreen] bounds];
instead of
CGRect frame = [[UIScreen mainScreen] applicationFrame];
Does it make a…

Joo Park
- 3,115
- 4
- 27
- 31
11
votes
3 answers
Manually Created UIWindow is Wrong Size
I am learning how to create an iOS app without Interface Builder (i.e. storyboards, xibs, etc.). Below is the basic app delegate class I am working with. The problem is that when displayed the UIWindow does not use up the full screen of the device…

joshwbrick
- 5,882
- 9
- 48
- 72