UIScreen.main.bounds wrong value on iphone X emulator [duplicate] - swift

This question already has answers here:
Seeing black bars at the top and bottom of the iPhone X Simulator
(11 answers)
Closed 5 years ago.
I'm trying to adapt an app to run on the iPhone X's screen but the UIScreen.main.bounds.size is always returning 375x667 and it should return 375x815.
I am running on a iPhone X simulator and everything works fine, except for this, so I am having a hard time on positioning elements on the screen as the wrong height is read.
I forced the height to be 710 just to see how it behaves.
Take a look at the picture and you will observe 2 crazy things:
The banner is cropped by the black area;
The corners of the app are rounded even with the black stripes.

You need to add Launch screen for iPhone X. Which size is Portrait size 1125px × 2436px & Landscape size 2436px × 1125px
Hope it helps!

Related

On iPhone X, UIApplication.sharedApplication.statusBarFrame.size.height is 20

on iPhone X, UIApplication.sharedApplication.statusBarFrame.size.height is 20.
As you know, on iphone X statusbar height is 44.
Because I set statusbar background using UIApplication.sharedApplication.statusBarFrame.size.height, there's weird blank white rectangle between statusbar and the contents.
But if I set background height 44 manually, that white rectangle disappear.
I cannot understand why UIApplication.sharedApplication.statusBarFrame.size.height is 20 on iPhone X. Do I need to do something else to get statusbar height correctly on iPhone X?
I noticed this too while testing my app on iPhone X. In my case I resolved this issue (status bar height became 44) by using LaunchScreen.storyboard instead of Launch Images. But in general it can be caused by lacking of a launch image with appropriate size for iPhone X (1125px × 2436px), if there is no appropriate launch image, also black stripes may appear at top and bottom of the app.

Why does iPhone app resize for iPad but not iPhone 5

Why do original iPhone applications (normal screen size like iPhone 4/4s) in Xcode resize perfectly for iPad automatically and not for the slightly larger iPhone 5 screen size?
To fit a iPhone 4 view into the iPad each point is scaled equally into two directions. The aspect ratio of a iPhone4-point doesn't change on the iPad screen.
To fit a iPhone 4 view onto the iPhone 5 screen, each point has to be scaled in vertical direction only. This will distort each point and the view, similar to the distortions you get when you watch a movie in the wrong aspect ratio. A circle on the iPhone 4 screen won't be a circle on the iPhone 5. So you can't physically resize the pixels like it's done on the iPad.
In iOS-Development Autoresizing Masks come to the rescue. But there is no way to figure out if your app looks good if the auto resizing scales the view to iPhone 5 size. You have to test each app on a iPhone 5 sized screen. Apple didn't want to do this, so they put an opt-in in place, which you actively had to enable. They choose to use the iPhone5 launch image for that.
If your app looks good when it's vertically scaled simply provide the appropriate launch image.
If you used best practices to develop your iPhone 4 app that's basically all that is needed.
iPhone 5 support needs to be explicitly added by supplying a "Default-568h" start image.

Iphone5: Black screen appearing at the top and bottom when running ios5 application on ios6 [duplicate]

This question already has an answer here:
Closed 10 years ago.
Possible Duplicate:
PhoneGap and iPhone 5: Remove top and bottom black stripes
Please enlighten me on this.
When i run my ios5 app on ios6 retina 4 inch simulator i can see a black screen at the top and bottom of the simulator. please help me in resolving this issue..
You must include a default splash screen image for iPhone 5. This acts as a flag, tells the device that your app is set up for the 4 inch display.
name of image must be: Default-568h#2x.png

iPhone 5 Applications (4 inch Screen) [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to develop or migrate apps for iPhone 5 screen resolution?
I'm (still) trying to convert one of my iPhone applications to iPhone 5, but it still looks like this in the simulator...
What am i doing and why won't it fill up the entire screen?
Have you provided a 4" sized launch image? That's the indicator that tells the OS that your application supports the full screen.
Have you selected in your UIView attributes inspector in XCode iPhone 5 screen size?
Please have a look at the url,
iPhone 5 TabBar not functioning in proper position
Now, in xib, at the right side, under 'Interface Builder Document', put a tick-mark on use autolayout and fix your objects in xib accordinlgy.
Download and install Xcode 4.5 GM. Set a 4-inch launch image for
your app. This is how you get 1136px screen height (without it, you
will get 960px with black margins on top and bottom).
Test your app, and hopefully do nothing else, since everything should work magically if you had set auto resizing masks properly. If you didn't, adjust your view layouts with proper auto resizing masks or look into Auto Layout if you only want to support iOS 6 going forward.
Also note: The auto-rotation API has changed completely, take a look at that as well if your application supports any rotation other than default.

UIView is not resizing on iPhone 5 Simulator [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to develop or migrate apps for iPhone 5 screen resolution?
I have UIViewController with a view that is 320x480. I made autoresizing mask setup for UIView to stretch it horizontally and vertically. But when I run it on iPhone 5 simulator there are black space at top and bottom.
Why UIView is not resized automatically from 480 to 568 pixels (vertically) to fill the empty space ?
You need to add Default-568h#2x.png launch image to your project with 1136x640px resolution.
See here:
How to develop or migrate apps for iPhone 5 screen resolution?