31

I am working on a iPhone App and I am trying to set a launch screen image. How can I set a launch screen image, is it possible to add a UIImageView and assign it a image?

If you need more information to answer the question then please let me know.

Thanks in advance

enter image description here

Kumar KL
  • 15,315
  • 9
  • 38
  • 60
Skywalker
  • 4,984
  • 16
  • 57
  • 122
  • from ios8 onwards, you have 2 options, use set of images or use 1 storyboard that will auto scale. To use set of images, click images.xcassets and then right click to select new launch images. fill in all the different sizes of image. After that set the images as your launch screen from the general tab. – Riandy Jun 24 '15 at 12:05
  • you should customize LaunchScreen.storyboard visit http://stackoverflow.com/a/41548620/5391914 – Hamed Jan 09 '17 at 13:31
  • This link works for me https://stackoverflow.com/questions/59169791/how-to-create-launchscreen-with-a-fullscreen-image-for-ios-in-react-native-which – Team Techi Nov 06 '20 at 11:44

3 Answers3

33

Yes, you can easily set a UIImageView in the LaunchScreen. Simply delete the pre-existing labels from the LaunchScreen.xib, add a UIImageView from the Interface Builder. Assign the following 4 constraints to that UIImageView with respect to the parent view:

  • Bottom Space to container
  • Top Space to container
  • Leading Space to Container
  • Trailing Space to Container

And finally set the image to the UIImageView.

Hope this helps you in what you wanted to do.

Update:

Have a look at the following image for further description:

danialzahid94
  • 4,103
  • 2
  • 19
  • 31
  • Thank you for the reply. I just have one question in which class do I set the image to the UIImageView? The launch screen.xib doesn't have a class associated with it. I usually set images within the viewDidLoad function of the classes. – Skywalker Jun 24 '15 at 12:26
  • You don't need a class to do that. You can simply set the constraints from the Interface Builder (.xib file) – danialzahid94 Jun 24 '15 at 12:28
  • 2
    yes, but where do I actually set the image to the UIImageView, usually we use self.view.backgroundColor = UIColor(patternImage: UIImage(named: "podcastbg.jpg")!) – Skywalker Jun 24 '15 at 12:31
  • Have a look at my updated answer. I have added an image for clarification on both things. – danialzahid94 Jun 24 '15 at 12:39
  • Works for React Native projects as well. Thanks. – jln-dk May 31 '16 at 13:10
  • If we use one image the content in the image got squished. So please add some answer. – SRI Dec 18 '17 at 07:41
  • @SRI if you want to use a single image and maintain aspect ratio, you should set View Mode to "Aspect Fill". This will resize the image so that the image doesn't squish. Let me know if this helps you – danialzahid94 Dec 18 '17 at 10:15
  • Will do the work!But a little `glitch` here, adding constraints may make the image resize during the launch process.To make it not to resize, just delete those constraints. – zionpi May 27 '20 at 07:41
6

In iOS 8 and later, you can create a XIB or storyboard file instead of a static launch image. When you create a launch file in Interface Builder, you use size classes to define different layouts for different display environments and you use Auto Layout to make minor adjustments.

https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/MobileHIG/LaunchImages.html

Oleksandr
  • 169
  • 10
-1

For adding a launchimage(or any type of image), in Xcode(9.4.1), simply go the Assets.xcassets and you can add it from the self-explanatory addition feature there. For my iphone app, i simply added it, in a jiffy. Also, you need to follow the instructions for adding constraints for the image, as described by one of the answerers with screenshot, above. Finally, you can save and test to see/verify your launch image appearing in the launch of your app.