Template Image doesn't get tinted on Launch Screen Storyboard
Asked Answered
M

3

5

I am setting up my launch screen with storyboard, and I'm using an image that is set to be a PDF template image. My goal is to put this image in a UIImageView and set tint color to it via Interface Builder.

This approach works fine if I have such image view in my Main.storyboard, but somehow, on LaunchScreen.storyboard, the image doesn't get tinted and takes on the actual color rendered on the PDF.

I looked around for information online but haven't found much info on proper use of template image on Launch Screen.

Is using tint color supported on Launch Screens? If it is, what's the appropriate way to set it up?

Mweru answered 29/9, 2017 at 14:29 Comment(0)
I
11

Launch screen storyboards work differently than a general storyboard. They are basically substitutes for launch screen images.

There are some restrictions for them: they cannot run code, nor they can use custom fonts etc. These restrictions include not being able to use tint colors.

Islamize answered 29/9, 2017 at 14:35 Comment(3)
Is this officially documented anywhere?Mweru
I'm afraid there is no central documentation for storyboard-based launch screen behaviour.Pressmark
Here is a doc about the topic, but it doesn't mention the specifics that I mentioned in the answer: developer.apple.com/documentation/xcode/…Pressmark
C
6

Tamás Sengel's answer is partially correct. But for now, you can use tintColor in LaunchStoroboard.

Follow these steps:

  1. Go to Assets.xcassets and set Render parameter of your image to Template Image.
  2. Then add your image and set it tintColor.

Notice that, if it doesn't work, this is not a reason to be upset. Try to reset your emulator by the following way: run Simulator and click Device -> Erase all Content and Settings. Аnd it should work.

Commeasure answered 24/2, 2021 at 21:2 Comment(1)
This works for me in Xcode 15Assortment
I
0

In my case, my image wasn't showing at all. So I read about the following trouble shooting hints somewhere:

  1. uncheck Clears Graphics Context in the attributes inspector of the UIImageView in your LaunchScreen.storyboard
  2. delete app
  3. restarting the iPhone/iPad
  4. reinstall the app
  5. try if it worked and repeat all the steps a couple of times until it works :D

After that I had no issues tinting a PDF image asset marked as Render as Template Image in the asset catalog. Tested on iOS 11 and 12.

Unfortunately those caching issues and all the Launchscreen caveats are poorly documented by Apple.

Igniter answered 8/4, 2019 at 11:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.