Skip to content

The easiest, pure-Swift library for presenting single page onboarding contents.

License

Notifications You must be signed in to change notification settings

yosshi4486/SinglePageOnboarding

Repository files navigation

SinglePageOnboarding

This package provides single page onboarding view controller that it is easy to provide onboarding experience.

Usage

Use Single Page Onboarding View Controller to configure single page onboarding content. After configuring the single page onboarding controller with the feature items and action, present it using the present(_:animated:completion:) method. UIKit displays onboarding content modaly over your app's content.

let onboarding = SinglePageOnboardingController(
    title: "Welcome to My App!",
    featureItems: [
        OnboadingFeatureItem(
            title: "More Personalized",
            description: "Top Stories picked for you and recommendations from Siri.",
            image: UIImage(systemName: "heart.fill")!,
            imageColor: UIColor.systemPink
        ),
        OnboadingFeatureItem(
            title: "New Articles Tab",
            description: "Discover latest articles.",
            image: UIImage(systemName: "newspaper")!,
            imageColor: UIColor.systemRed
        ),
        OnboadingFeatureItem(
            title: "Watch Video News",
            description: "You can now watch video news in Video News Tab.",
            image: UIImage(systemName: "play.rectangle.fill")!,
            imageColor: UIColor.blue
        )
    ]
)

onboarding.action = OnboardingAction(
    title: "Agree and Continue",
    handler: { action in
        onboarding.dismiss(animated: true, completion: nil)
    }
)

self.present(onboarding, animated: true, completion: nil)

Also, please check sample project that is located here:

override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
let onboarding = SinglePageOnboardingController(
title: "Welcome to My App!",
featureItems: [
OnboadingFeatureItem(
title: "More Personalized",
description: "Top Stories picked for you and recommendations from Siri.",
image: UIImage(systemName: "heart.fill")!,
imageColor: UIColor.systemPink
),
OnboadingFeatureItem(
title: "New Articles Tab",
description: "Discover latest articles.",
image: UIImage(systemName: "newspaper")!,
imageColor: UIColor.systemRed
),
OnboadingFeatureItem(
title: "Watch Video News",
description: "You can now watch video news in Video News Tab.",
image: UIImage(systemName: "play.rectangle.fill")!,
imageColor: UIColor.blue
),
],
action: OnboardingAction(
title: "Agree and Continue",
handler: { action in
// Do something, such as storing flag in `UserDefaults`.
}
)
)
let baseFooterText = NSLocalizedString("Please read and agree terms of use and privacy policy.", comment: "")
let attributedString = NSMutableAttributedString(string: baseFooterText, attributes: [
.foregroundColor: UIColor.label,
.font: UIFont.preferredFont(forTextStyle: .body)
])
attributedString.addAttribute(.link,
value: "https://github.com/yosshi4486/SinglePageOnboarding",
range: NSString(string: baseFooterText).range(of: NSLocalizedString("terms of use", comment: "")))
attributedString.addAttribute(.link,
value: "https://github.com/yosshi4486/SinglePageOnboarding",
range: NSString(string: baseFooterText).range(of: NSLocalizedString("privacy policy", comment: "")))
onboarding.footerAttributedString = attributedString
onboarding.footerTextViewDelegate = self
self.present(onboarding, animated: true, completion: nil)
}

Installation

Install this package from url(https://github.com/yosshi4486/SinglePageOnboarding) via swift package manager.

Contribution

I'm looking forward for your issues or pull requests😊

Specifically...

Word corrections

I'm not native english language speaker, some sentences may have miss.

About

The easiest, pure-Swift library for presenting single page onboarding contents.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages