SplashKit
可自定义的启动画面系统,能够处理多个启动画面导航和显示
安装
CocoaPods
要使用 CocoaPods 安装 SplashKit,请将以下行添加到您的 Podfile
中。
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!
pod 'SplashKit'
Carthage
Carthage 是一个去中心化的依赖关系管理器,它会构建您的依赖项并为您提供二进制框架。
您可以使用以下命令通过 Homebrew 安装 Carthage
$ brew update
$ brew install carthage
要在 Xcode 项目中使用 Carthage 集成 SplashKit,请在您的 Cartfile
中指定它
github 'Digipolitan/splash-kit ~> 1.0
运行 carthage update
构建框架,并将构建好的 SplashKit.framework
拖动到您的 Xcode 项目中。
基础知识
默认启动画面
首先将键 环境 添加到您的 Info.plist 中,检查 RuntimeEnvironment 仓库。
<key>environment</key><string>staging</string>
然后创建您的启动画面视图 (.xib),使其继承自 DefaultSplashScreenViewController,并在 AppDelegate.swift 中设置启动画面动作,如下:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = SplashNavigationController.newInstance(splashViewControllers:
DefaultSplashViewController(nibName: "AppDefaultSplashViewController", bundle: nil)) { [weak self] _ in
guard let target = self,
let window = target.window else {
return
}
UIView.transition(with: window, duration: 1, options: .transitionCrossDissolve, animations: {
UIView.setAnimationsEnabled(false)
window.rootViewController = UINavigationController(rootViewController: ViewController())
UIView.setAnimationsEnabled(true)
}, completion: nil)
}
window.makeKeyAndVisible()
self.window = window
return true
}
以下是使用默认启动画面的示例。
捐助
请查阅 CONTRIBUTING.md 了解更多详情!
本项目遵循 贡献者公约行为准则。通过参与,您被期望遵守此准则。请向 [email protected] 报告任何不可接受的行为。
许可证
SplashKit 项目受 BSD 3-Clause 许可证 概括。