在 swift 5 中隐藏初始屏幕中的标签栏
hide tab bar in splash screen in swift 5
我已经在 iOS 应用程序中实现了闪屏。它有 2-3 秒的持续时间,但我主屏幕上的 tabarcontroller 显示在启动画面中。enter image description here
一种方法是在 AppDelegate 中为启动画面添加一个单独的 window。这样一来,您就可以将选项卡栏控制器保留为根视图控制器。
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let launchView = UIStoryboard(name: "LaunchScreen", bundle: nil).instantiateInitialViewController()?.view ?? UIView()
func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
launchView.frame = window?.frame ?? .zero
window?.addSubview(launchView)
DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
// splash screen shows for 5 seconds
launchView.removeFromSuperview()
}
return true
}
}
我已经在 iOS 应用程序中实现了闪屏。它有 2-3 秒的持续时间,但我主屏幕上的 tabarcontroller 显示在启动画面中。enter image description here
一种方法是在 AppDelegate 中为启动画面添加一个单独的 window。这样一来,您就可以将选项卡栏控制器保留为根视图控制器。
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
let launchView = UIStoryboard(name: "LaunchScreen", bundle: nil).instantiateInitialViewController()?.view ?? UIView()
func application(_ application: UIApplication, didFinishLaunchingWithOptions
launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
launchView.frame = window?.frame ?? .zero
window?.addSubview(launchView)
DispatchQueue.main.asyncAfter(deadline: .now() + 5) {
// splash screen shows for 5 seconds
launchView.removeFromSuperview()
}
return true
}
}