17

I'm trying out the new funky Launch Screen.xib (storyboard) instead of using launcher images in my iOS app.

On my first page I have a tiled background image called bodybg@2x.png which I put on the background of that first page via code:

self.view.backgroundColor = [UIColor colorWithPatternImage: [UIImage imageNamed:@"bodybg.png"]];

So I could do with having the same background on the Launch Screen. Presumably there's no way to execute code when the Launch Screen.xib is loaded, so how do I go about putting a tiled, retina background on a Launch Screen.xib?

Matt Parkins
  • 24,208
  • 8
  • 50
  • 59
  • I'm thinking my only option is to manually tile a giant image at a res suitable for the iPhone 6+ and constrain it to the sides. It might just look a bit naff on the iPhone 4S non-retina. – Matt Parkins Oct 28 '14 at 17:06
  • 1
    For what it's worth, I tried inserting a custom tiling `UIImageView` class into the Launch Screen. But custom classes aren't allowed, as I would have found if I had googled it first! – Karl Voskuil Nov 19 '14 at 19:37
  • I just used launch screenshots in the end. If I have time I might look to see if putting a 2x sized texture into a UIImageView (an unrolled tile-able texture) in the hope that it works it out, but I'm not near a project to test it. – Matt Parkins Nov 20 '14 at 14:28

1 Answers1

22
  1. Add the image to an asset catalog.
  2. Choose Editor > Show Slicing.
  3. Change slicing configurations as the following (100x100 image is used here): Slicing configuration (This tells Xcode that there are no fixed parts and the entire image should be tiled).
  4. Add UIImageView to your launch screen and use the previous image. Set the mode to Scale to Fill and the image will be tiled to fill the image view.
Hejazi
  • 16,587
  • 9
  • 52
  • 67
  • 1
    Just tried that in Xcode 8.3 but didn't work for me in the same way. Did anything change here with latest Xcode? – Kai Mar 31 '17 at 13:03
  • @Kai Still works for me on Xcode 8.3. What was the problem when you tried? – Hejazi Apr 02 '17 at 07:28
  • My launch storyboard doesn't seem to be loading the tile when I build with Xcode 8.3.2. I see the tiled image in the Xcode editor, but when I launch my app, the area that should be displaying the tiled image is just white. – Greg May 23 '17 at 21:18
  • It looks like building the app in Xcode 8.2.1, then reinstalling it with Xcode 8.3.2 has got it working correctly. – Greg May 23 '17 at 21:36
  • It doesn't seems to work with Xcode 8.3.2. It started showing well formed pattern in storyboard but while running app, Launchscreen still have just black background. – Vikas Jul 27 '17 at 13:06
  • 1
    This is working perfectly on Xcode 11. Thanks @Hejazi great find! – mota Oct 15 '19 at 13:33