SWIFT-获取启动图片

// 获取启动图
    class func launchImage() -> UIImage? {
        var lauchImage: UIImage!
        var viewOrientation: String!
        let viewSize = UIScreen.main.bounds.size
        let orientation: UIInterfaceOrientation = UIApplication.shared.statusBarOrientation
        
        if orientation == .landscapeLeft || orientation == .landscapeRight {
            viewOrientation = "Landscape"
        }else{
            viewOrientation = "Portrait"
        }
        let imagesInfoArray = Bundle.main.infoDictionary!["UILaunchImages"]
        for dict: Dictionary in imagesInfoArray as! Array {
            let image = UIImage(named: dict["UILaunchImageName"] as! String)
            let imageSize = CGSize(width: image?.size.width ?? 0, height: image?.size.height ?? 0)
            if imageSize.equalTo(viewSize) && viewOrientation == dict["UILaunchImageOrientation"]! as? String {
                lauchImage = image
            }
        }
        
        return lauchImage
    }

你可能感兴趣的:(SWIFT-获取启动图片)