I’m hoping I can get some help explaining why this is happening. I have been working on switching my app I’ve been learning / building from UIKit to SwitfUI since this seems to be the future… plus it’s fun to learn.
I’ve got my plist setup with the background and image
And the very first time I run it when the simulator opens or I clear and erase the simulator is this:
However, every time after I run the app, the image stretches.
When I try it on my phone, it seems to stretch every time. I’m not sure what is happening here. Is it just that SwiftUI needs more work or is there a setting I’m missing?
6
Answers
Resize your image to @1x, @2x, and @3x versions when @1x is 200x200px.
Then upload it to Assets folder and change info.plist
Image Name
.This worked for me.
I have resolved the same issue with changing the dimensions of SVG.
<svg width="390px" height="844px" viewBox="0 0 1500 1500"
I’ll mention this because it technically worked for me.
Turn off the device. Turn it on again. Reinstall the app. Launch screen is not stretched anymore!
It’s a strange behavior and it makes me wonder if it’s a bug with iOS and not with swiftui.
I got this answer from a comment on this article.
This seems to be a SwiftUI Bug, which still isn’t fixed. The only way to go around this bug is to go back to storyboards.
You have to create a launch screen storyboard and link it to your project.
To do so:
If you are using
.svg
images for the launch screen (works on device).I hope it will be useful, to this recurring question and even today with Xcode 14 it is not really solved.
This may help:
It works for me.