-1

I am trying to assign the right LaunchImage for the Device/Dimensions to a UIImage.

This works only for a specific device in this case for iPhone6 portrait.

UIImage(named: "LaunchImage-800-667h@2x.png")

Is there away where the right launchImage can be assigned to UIImage?

When launching the app the right launchImage is used but NOT when assigning launchImage to UIImage.

I also tried this, and it return a launchImage but not the right one for the device.

UIImage(named: "LaunchImage")
rmaddy
  • 314,917
  • 42
  • 532
  • 579
Nouras
  • 129
  • 2
  • 12
  • [possible duplicate](http://stackoverflow.com/questions/19410066/ios-7-xcode-5-access-device-launch-images-programatically) – meth Feb 25 '16 at 22:48

1 Answers1

2

A launch image is what shows up on the screen before your app runs.

Thus, you cannot specify a launch image in code (e.g. UIImage(named: "LaunchImage"), because the launch image appears before you code ever has a chance to run - there would be no place to put such code.

The launch image is determined entirely by settings in your Info.plist (plus the asset catalog if you are using that).

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • 2
    i guess, he wants to reach the launch image of the app after the app starts. Probably he will use it inside the app somewhere. – meth Feb 25 '16 at 22:52
  • @meth But he _shouldn't_ want that. A launch image is an image _of_ your app, not an image to be shown _in_ your app. – matt Feb 25 '16 at 22:55
  • 1
    i also think like that but as i commented under the question, there exists a question demanding this and some others around needed it before. – meth Feb 25 '16 at 22:58
  • 2
    The question is not about how to get LaunchImage to work. (in my case it is working fine). The question clearly says how to assign a LaunchImage to UIImage. So basically how to access the assets folder and retrieve the right image for the device. – Nouras Feb 25 '16 at 23:09
  • And by the way I am able to access the assets folder for launchImage like so UIImage(named: "LaunchImage-800-667h@2x.png"), but this will only return the right image for iPhone 6 but not for other devices. My main point here is how to be able to get the right image for assets depending on what device is used. – Nouras Feb 25 '16 at 23:14
  • @Nouras Why not just make a different actual image set, based on the device type, consisting of the same image? – matt Feb 25 '16 at 23:16
  • 3
    I thought since launchImage picks the right image for the device when launching the app then their should be a way to also pick the right image when assigning image to UIImage. To use the same images from launchImage I can use this list http://stackoverflow.com/a/20045142/5900874 It seems the closest solution so far. – Nouras Feb 25 '16 at 23:25