简体   繁体   English

模板图像不会在启动屏幕情节提要上着色

[英]Template Image doesn't get tinted on Launch Screen Storyboard

I am setting up my launch screen with storyboard, and I'm using an image that is set to be a PDF template image.我正在使用情节提要设置我的启动屏幕,并且我正在使用设置为 PDF 模板图像的图像。 My goal is to put this image in a UIImageView and set tint color to it via Interface Builder.我的目标是将此图像放入UIImageView并通过 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.如果我的Main.storyboard有这样的图像视图,则这种方法工作正常,但不知何故,在LaunchScreen.storyboard ,图像不会着色并呈现在 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?如果是,设置它的合适方法是什么?

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 .它们有一些限制:它们不能运行代码,也不能使用自定义字体等。这些限制包括不能使用色调颜色

Tamás Sengel's answer is partially correct. Tamás Sengel 的回答部分正确。 But for now, you can use tintColor in LaunchStoroboard.但是现在,您可以在 LaunchStoroboard 中使用tintColor

Follow these steps:请按照以下步骤操作:

  1. Go to Assets.xcassets and set Render parameter of your image to Template Image .转到Assets.xcassets并将图像的Render参数设置为Template Image
  2. Then add your image and set it tintColor .然后添加您的图像并将其设置为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 .尝试通过以下方式重置模拟器:运行模拟器并单击Device -> Erase all Content and Settings Аnd it should work. Аnd 它应该工作。

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.storyboardLaunchScreen.storyboardUIImageView的属性检查器中取消选中Clears Graphics Context
  2. delete app删除应用
  3. restarting the iPhone/iPad重新启动 iPhone/iPad
  4. reinstall the app重新安装应用程序
  5. try if it worked and repeat all the steps a couple of times until it works :D尝试它是否有效并重复所有步骤几次直到它有效:D

After that I had no issues tinting a PDF image asset marked as Render as Template Image in the asset catalog.之后,我在为资产目录中标记为“渲染为模板图像”的 PDF 图像资产着色时没有任何问题。 Tested on iOS 11 and 12.在 iOS 11 和 12 上测试。

Unfortunately those caching issues and all the Launchscreen caveats are poorly documented by Apple.不幸的是,Apple 没有很好地记录这些缓存问题和所有 Launchscreen 警告。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM