测试已测试 | ✗ |
Lang语言 | SwiftSwift |
许可证 | MIT |
发布上次发布 | 2016年11月 |
SwiftSwift 版本 | 3.0 |
SPM支持 SPM | ✗ |
由 Eugene Mozharovsky 维护。
OnboardingKit
是一个简单且交互式的框架,用于使 iOS 入门体验变得简单而有趣!
导入模块。
import OnboardingKit
添加一个继承自 OnboardingView
的 UIView
实例。传统上,您可以通过 Storyboard 或手动操作完成此操作。
以必须方法的方式实现 OnboardingViewDataSource
和 OnboardingViewDelegate
协议。您必须做的是让 OnboardingView
了解它应该构建多少页面以及为这些页面提供配置。
extension DataModel: OnboardingViewDataSource, OnboardingViewDelegate {
func numberOfPages() -> Int {
return 1
}
func onboardingView(_ onboardingView: OnboardingView, configurationForPage page: Int) -> OnboardingConfiguration {
return OnboardingConfiguration(
image: UIImage(named: "DemoImage")!,
itemImage: UIImage(named: "DemoIcon")!,
pageTitle: "Demo Title",
pageDescription: "Demo Description Text!",
backgroundImage: UIImage(named: "DemoBackground"),
topBackgroundImage: nil, // your image here
bottomBackgroundImage: nil // your image here
)
}
OnboardingConfiguration
以这种方式实现
public struct OnboardingConfiguration {
let image: UIImage
let itemImage: UIImage
let pageTitle: String
let pageDescription: String
let backgroundImage: UIImage?
let topBackgroundImage: UIImage?
let bottomBackgroundImage: UIImage?
}
如果您需要为 PageView
提供自定义配置,可以通过代理的方法 onboardingView(_:, configurePageView _:, atPage _:)
实现。
func onboardingView(_ onboardingView: OnboardingView, configurePageView pageView: PageView, atPage page: Int) {
pageView.titleLabel.textColor = UIColor.white
pageView.titleLabel.layer.shadowOpacity = 0.6
pageView.titleLabel.layer.shadowColor = UIColor.black.cgColor
pageView.titleLabel.layer.shadowOffset = CGSize(width: 0, height: 1)
pageView.titleLabel.layer.shouldRasterize = true
pageView.titleLabel.layer.rasterizationScale = UIScreen.main.scale
if DeviceTarget.IS_IPHONE_4 {
pageView.titleLabel.font = UIFont.boldSystemFont(ofSize: 30)
pageView.descriptionLabel.font = UIFont.systemFont(ofSize: 15)
}
}
就是这样。 :]
OnboardingKit
在 MIT 许可证下可用,有关更多信息,请参阅 LICENSE 文件。