将启动图像用于启动屏幕 [英] Use Launch Image for Launch Screen
问题描述
使用xcode 7,我想为所有iPhone创建具有相同图像的启动屏幕.
using xcode 7 I wanna to create a Launch Screen with the same image for all iPhones.
在应用程序的主要目标->常规->应用程序图标和启动图像->启动图像源中,我选择了"LaunchImage"
In the application main target -> General -> App Icones and Launch Images -> Launch Image Source I have selected the "LaunchImage"
在资产中,我创建了一个LaunchImage(应用程序图标和启动图像->新的iOS启动图像),然后将所有适用于各种设备的图像放入其中.
In the assets I created a LaunchImage (App Icons & Launch Images->New iOS Launch Image) and I put all the images applicable to the various devices.
启动我的应用程序时,没有启动图像.有人知道为什么吗?感谢所有人
When I start my app there isn't launch image. Anyone know why? Thanks to all
推荐答案
我使用以下代码解决了该问题:
I solved it with this code:
extension UIImage {
convenience init?(fullscreenNamed name: String) {
switch UIScreen.mainScreen().bounds.size.height {
case 480: //iPhone 4/4s
self.init(named: "\(name)-700@2x.png")
case 568: //iPhone 5/5s
self.init(named: "\(name)-700-568h@2x.png")
case 667: //iPhone 6/6s
self.init(named: "\(name)-800-667h@2x.png")
case 736: //iPhone 6+/6s+
self.init(named: "\(name)-800-Portrait-736h@3x.png")
default:
self.init(named: name)
}
}
}
我为使用中的设备屏幕获取正确的图像"LaunchImage".
I take in "LaunchImage" the right image for the device screen in use.
@Pyro,谢谢您的帮助
@Pyro, thanks for your help
这篇关于将启动图像用于启动屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!