如何在Swift Xcode iOS中以编程方式延迟启动屏幕的启动 [英] How can I delay splash launch screen programmatically in Swift Xcode iOS
本文介绍了如何在Swift Xcode iOS中以编程方式延迟启动屏幕的启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在LaunchStoreyboard
的imageView
中放置了image
.如何以编程方式延迟图像的时间?
I have put an image
in imageView
in LaunchStoreyboard
. How can I delay the time of image programmatically?
这是 Apple推出的屏幕指南 .
Here is the Launch Screen Guideline from Apple.
以下是启动屏幕视图"控制器的代码:
import UIKit
class LaunshViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.delay(0.4)
}
func delay(_ delay:Double, closure:@escaping ()->()) {
let when = DispatchTime.now() + delay
DispatchQueue.main.asyncAfter(deadline: when, execute: closure)
}
}
推荐答案
在AppDelegate类中放置一行代码-
Put one line of code in AppDelegate class -
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
Thread.sleep(forTimeInterval: 3.0)
// Override point for customization after application launch.
return true
}
这篇关于如何在Swift Xcode iOS中以编程方式延迟启动屏幕的启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文