欢迎来到 1.0.0

WelcomeAboard 1.0.0

Leandro Romano 维护。



RKit

CocoaPods iOS Twitter: @leandroromn


欢迎来到 WelcomeAboard,这是一个快速展示您应用程序主要功能的库。

此仓库是为了方便创建类似于原生 Apple 应用程序的欢迎屏幕而创建的。

安装

CocoaPods

要在您的 iOS 项目中安装 WelcomeAboard,请在您的 Podfile 中添加以下行

pod 'WelcomeAboard'

然后,在终端中运行以下命令

$ pod install

恭喜! 🥳
WelcomeAboard 已成功安装到您的项目中。


如何使用

首先,将 WelcomeAboard 导入到您的 UIViewController 类中。
然后,创建必要的模型来填充 WABaseView 和子组件。

import WelcomeAboard

class ViewController: UIViewController {
    override func loadView() {
        super.loadView()
        let content = createWAContent()
        view = WABaseView(content: content)
    }

    private func createWAContent() -> WAContent.Base {
        let color = UIColor(red:0.90, green:0.22, blue:0.31, alpha:1.00)
        let title = WAContent.Title(format: .multiline(welcomeText: "Welcome to"),
                                    text: "WelcomeAboard")

        let items = [
            WAContent.Card(title: "Receive New Users",
                           resume: "Tell us about your application, explain the main features and what else you want to tell!",
                           icon: UIImage(systemName: "person.2.square.stack.fill"),
                           iconTintColor: color),
            WAContent.Card(title: "Highlight Features",
                           resume: "I'm sure your application contains incredible features. Use this space to give more visibility.",
                           icon: UIImage(systemName: "text.bubble.fill"),
                           iconTintColor: color),
            WAContent.Card(title: "Notify Bugfixes",
                           resume: "Nobody likes to receive a bug report. Informing that annoying problem has been fixed is much more nicer.",
                           icon: UIImage(systemName: "hammer.fill"),
                           iconTintColor: color)
        ]

        let button = WAContent.Button(text: "Continue", backgroundColor: color) { [weak self] in
            self?.dismiss(animated: true)
        }

        return WAContent.Base(backgroundColor: .white,
                              title: title,
                              cards: items,
                              button: button)
    }
}

⚠️ 请,将字符串提取到单独的文件中。

在这个示例中,WABaseView 是在 loadView 方法中创建的,但这是不需要的。您可以在任何位置创建 WABaseView

内容模型

WAContent.Base

其他模型构建 WABaseView 的容器。

名称 类型 必需
backgroundColor UIColor
title WAContent.Title
cards [WAContent.Card]
button WAContent.Button

WAContent.Title

负责标题视图的模型。

名称 类型 必需
格式 WAContent.Title.Format
text String

WAContent.Title.Format

负责标题视图格式的模型。可以选择 .oneline 以获得示例相同的输出结果,或者选择 .multiline 选项以指定欢迎文本和标题文本。

  • .oneline
  • .multiline
    • welcomeText: String
名称 类型 必需
textAlignment NSTextAlignment 🟨

WAContent.Card

负责 WACardView 视图的模型。属性 iconTintColor 不是必需的。默认值为 .black

名称 类型 必需
title String
titleFont UIFont
resume String
resumeFont UIFont
icon UIImage?
iconTintColor UIColor?

WAContent.Button

负责 WAPrimaryButton 按钮的模型。属性 action 不是必需的。请记住使用 weak self 来避免循环引用。

名称 类型 必需
text String
backgroundColor UIColor
action (() -> Void)?
let button = WAContent.Button(text: "Continue", backgroundColor: .orange) { [weak self] in
    self?.dismiss(animated: true)
}

credits

WelcomeAboard最初由Leandro Romano编写,其简单的目标是利用预览功能加速开发,这些功能已成为苹果原生应用的行业标准。

欢迎视图布局由Apple创建。

贡献和支持

欢迎提出建议或提交pull请求。

如果您添加了视觉特效,请记得运行/更新快照测试。

祝您使用欢迎使用愉快⛵️