I have a requirement to set a Gradient background to the launch screen with a UIImageView
in the center which shows the app logo . I tried having a view controller but I realised code will never be invoked.
我需要在启动屏幕上设置一个渐变背景,中间有一个显示应用徽标的UIImageView。我尝试了一个视图控制器,但我意识到代码永远不会被调用。
I need some way to get behaviour as the code below does
我需要一些方法来获得行为,如下面的代码所做的那样
self.view.backgroundColor = UIColor(patternImage: UIImage(named: "background.png")!)
I went through lot of answers about the same topic, most of the questions on gradient colour don't seem to have any additional requirements like showing another image other than the background .
我对同一主题进行了大量的回答,关于渐变色的大多数问题似乎没有任何额外的要求,比如显示除背景之外的其他图像。
I can hardcode the color in IB but i don't get the gradient.
我可以在IB中硬编码颜色,但我没有得到渐变。
1 个解决方案
#1
3
You cannot run code or use any custom classes in the Launch Screen. Basically the launch screen can use an interface builder file and accommodate size classes / auto layout, but you cannot create a gradient in code like you have.
您无法在启动屏幕中运行代码或使用任何自定义类。基本上,启动屏幕可以使用界面构建器文件并适应大小类/自动布局,但您无法在代码中创建渐变。
You'll have to supply a stretchable image, which contains enough data for it to be viable in all resolutions.
您必须提供一个可伸缩的图像,其中包含足够的数据,以便在所有分辨率下都可行。
#1
3
You cannot run code or use any custom classes in the Launch Screen. Basically the launch screen can use an interface builder file and accommodate size classes / auto layout, but you cannot create a gradient in code like you have.
您无法在启动屏幕中运行代码或使用任何自定义类。基本上,启动屏幕可以使用界面构建器文件并适应大小类/自动布局,但您无法在代码中创建渐变。
You'll have to supply a stretchable image, which contains enough data for it to be viable in all resolutions.
您必须提供一个可伸缩的图像,其中包含足够的数据,以便在所有分辨率下都可行。