Git Product home page Git Product logo

swiftyonboard's Introduction

SwiftyOnboard

A simple iOS framework that allows developers to create onboarding experiences.

Swift Version Build Status License CocoaPods Carthage compatible Platform

SwiftyOnboard makes it easy to add onboarding to any iOS application. SwiftyOnboard handles all of the logic behind the pagination of views, which allows you to quickly add a highly customizable onboarding to your app, all in a lightweight framework.

Contents

Requirements

  • iOS 12.0+
  • Xcode 10.3+

Installation

CocoaPods

You can use CocoaPods to install SwiftyOnboard by adding this to your Podfile:

use_frameworks!
pod 'SwiftyOnboard'

If you get the Unable to find a specification for `SwiftyOnboard`. error after running pod install.

Run the following commands on your project directory:

pod repo update
pod install

Carthage

To install via Carthage add this to your Cartfile:

github "juanpablofernandez/SwiftyOnboard"

Manually

  1. Drag and drop SwiftyOnboard.swift SwiftyOnboardOverlay.swift SwiftyOnboardPage.swift in your project.
  2. That's it!

Usage

  1. Import SwiftyOnboard module to your ViewController class
import SwiftyOnboard
  1. Add SwiftyOnboard to ViewController, then set dataSource and delegate for it
class ViewController: UIViewController {
    override func viewDidLoad() {
            super.viewDidLoad()

            let swiftyOnboard = SwiftyOnboard(frame: view.frame)
            view.addSubview(swiftyOnboard)
            swiftyOnboard.dataSource = self
        }
}
  1. Conform your ViewController to SwiftyOnboardDataSource protocol and implement all the methods, e.g.
extension ViewController: SwiftyOnboardDataSource {

        func swiftyOnboardNumberOfPages(swiftyOnboard: SwiftyOnboard) -> Int {
            return 3
        }

        func swiftyOnboardPageForIndex(swiftyOnboard: SwiftyOnboard, index: Int) -> SwiftyOnboardPage? {
            let page = SwiftyOnboardPage()
            return page
        }
}
  1. SwiftyOnboard works with default implementation. Override it to customize its behavior

Properties

SwiftyOnboard has the following properties:

public var dataSource: SwiftyOnboardDataSource?

An object that supports the SwiftyOnboardDataSource protocol and can provide views to populate the SwiftyOnboard.

public var delegate: SwiftyOnboardDelegate?

An object that supports the SwiftyOnboardDelegate protocol and can respond to SwiftyOnboard events.

public var shouldSwipe: Bool

Whether or not swiping is enabled [default = true].

public var fadePages: Bool

Whether or not pages will fade upon transition [default = true].

Methods

SwiftyOnboard class has the following methods:

func goToPage(index: Int, animated: Bool)

This method allows you to move to a certain page in the onboarding.

Protocols

The SwiftyOnboard follows the Apple convention for data-driven views by providing two protocol interfaces, SwiftyOnboardDataSource and SwiftyOnboardDelegate.

SwiftyOnboardDataSource

SwiftyOnboardDataSource protocol has the following methods:

func swiftyOnboardNumberOfPages(swiftyOnboard: SwiftyOnboard) -> Int

Return the number of items (pages) in the onboarding.

func swiftyOnboardViewForBackground(swiftyOnboard: SwiftyOnboard) -> UIView?

Return a view to be displayed as the background of the onboarding.

func swiftyOnboardPageForIndex(swiftyOnboard: SwiftyOnboard, index: Int) -> SwiftyOnboardPage?

Return a view (page) to be displayed at the specified index in the onboarding.

func swiftyOnboardViewForOverlay(swiftyOnboard: SwiftyOnboard) -> SwiftyOnboardOverlay?

Return an overlay (view) to be displayed on top of the onboarding pages. e.g. [The continue and skip buttons which don't move with the pages, also included is the page control]

func swiftyOnboardOverlayForPosition(swiftyOnboard: SwiftyOnboard, overlay: SwiftyOnboardOverlay, for position: Double)

Edit the overlay (view) for the desired position. e.g. [Change the "continue button" text to "Done", when the last page is reached]

func swiftyOnboardBackgroundColorFor(_ swiftyOnboard: SwiftyOnboard, atIndex index: Int) -> UIColor?

Set the background color for the page at the given index. (Very useful when you have pages with different background colors)

SwiftyOnboardDelegate

SwiftyOnboardDelegate protocol has the following methods:

func swiftyOnboard(swiftyOnboard: SwiftyOnboard, currentPage index: Int)

This method is called whenever a page is shown, it holds the index to that page. It is called regardless of whether the page was swiped programmatically or through user interaction.

func swiftyOnboard(swiftyOnboard: SwiftyOnboard, leftEdge position: Double)

This method is called whenever the pages are scrolling, it holds the current distance between the left side of the screen and the left side of the first page.

func swiftyOnboard(swiftyOnboard: SwiftyOnboard, tapped index: Int)

This method is called whenever a page is tapped by the user, it holds the index of the tapped page.

Notes

  • Landscape mode is not supported

Contribute

Contributions are welcomed! There are however certain guidelines you must follow when you contribute:

  • Have descriptive commit messages.
  • Make a pull request for every feature (Don't make a pull request that adds 3 new features. Make an individual pull request for each of those features, with a descriptive message).
  • Don't update the example project, or any other irrelevant files.

I want to see your amazing onboarding. Take screenshots and/or record a gif and send it my way!

License

Distributed under the MIT license. See LICENSE for more information.

swiftyonboard's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

swiftyonboard's Issues

Skip and Continue Buttons do nothing

Have followed the Readme and I can see the onboarding screens and can swipe between them but when trying to press the Continue or Skip buttons nothing happens other than the button doing the animation to show its been pressed

Running the Example works as intended but it seems to be using an old version of SwiftyOnboard

I have tried copying the code from the Example ViewController.swift into my project and updating the couple of things that have changed but again the Continue and Skip buttons don't Continue or Skip

UIPageControl dots isn't connected

UIPageControl dots isn't connected with code, it doesn't work, pages is working, but dots not moving

@IBOutlet weak var contentControl: UIPageControl! --- with empty circle connection, and got error if launch without connection

Swift 4
xCode 9

Apple's update to their API policy - Required Reason in Privacy manifest

Describe the feature or problem you’d like to solve

From Fall 2023 Apple starts rolling out new privacy requirements, The apps and third-party SDKs should contain a privacy manifest file when they access required reason API. SkeletonView SDK uses UserDefaults which is required description of use in PrivacyManifest.
Otherwise, apps that don’t describe their use of required reason API in their privacy manifest file won’t be accepted by App Store Connect. Here is a link to the [Apple documentation].(https://developer.apple.com/documentation/bundleresources/privacy_manifest_files/describing_use_of_required_reason_api).

Proposed solution

Add a PrivacyInfo.xcprivacy file and the following information to the Privacy Accessed API Types section
Privacy Accessed API Type: User Defaults
Privacy Accessed API Reasons: CA92.1: Access info from same app, per documentation

Additional context

Apple documentation

Can't override page init

Bug

If I try to customize some constraints, I have a problem. My first idea is to create a SwiftyOnboardPage class and override thesetUp ()method to my constraints. Its not work, after that I try to override init () method, butinit () in SwiftyOnboardPage` does not have a public type.

Solution

After then I updated the original init () method in SwiftyOnboardPage and all works pretty well.

Bug

Same problem is override setUp method

Solution

Set setUp method as open

If you have any other idea to craate your own page, please tell me.

How do I code what view controller is linked to the continue button?

Hi, I didn't see in the documentation or the example a guide on how to link up the continue button to link the click action to another view controller did I miss something?

Also it would seem you would want to run this in a first run situation, do you have a preferred method of detecting first run and launching SwiftyOnboard?

Page Control doesn't synchronize with a swipe action

Dear developer,
I tried to install this SwiftyOnboard pod into my project, but its page control doesn't synchronize with a swipe action.
For example, even if I swipe the display to the next page, the dot point of page control doesn't move.
Plus, even if I tap the dot, the display doesn't move to the designated page.
In order to synchronize page control and swipe and tap actions like the demo, where and which code should I add?
My environment is Xcode 9 beta 6, macOS Sierra.
I'm a beginner who started learning of iOS development 2 months ago, so I wonder if you cloud explain a solution to me simply.
Thanks in advance from Japan.

Different styles per page.

Setting the style per page is protected. Perhaps consider exposing the set method to set the style?

I'm open to working on it but would like to know your thoughts before trying anything

Build fail on iOS 11/Swift 4

Trying to use this and I'm getting a build time error from Swift Compiler and it appears some changes from Swift 3 to Swift broke part..

Argument of '#selector' refers to instance method 'didTapPageControl' that is not exposed to Objective-C

'init(colorLiteralRed:green:blue:alpha:)' is unavailable: This initializer is only meant to be used by color literals

Argument of '#selector' refers to instance method 'tappedPage()' that is not exposed to Objective-C

swiftyOnboardOverlayForPosition never being called

Hello, I tried following the examples, it worked well for the CustomPage, everything shows as expected, unfortunately it's not working for the CustomOverlay... Don't know why... I can modify the elements (i.e the buttons) programmatically but it seems to never update itself.

func swiftyOnboardOverlayForPosition(_ swiftyOnboard: SwiftyOnboard, overlay: SwiftyOnboardOverlay, for position: Double) {
        print("====> test <====")
        let overlay = overlay as! CustomOverlay
        let currentPage = round(position)
        overlay.pageControl.currentPage = Int(currentPage)
        overlay.buttonContinue.tag = Int(position)
        if currentPage == 0.0 || currentPage == 1.0 {
            overlay.buttonContinue.isHidden = true
        } else {
            overlay.buttonContinue.isHidden = false
            overlay.buttonContinue.setTitle("Get Started!", for: .normal)
        }
    }

Test is never printed. And using default overlay gets the controlPage updated but not the buttons.

Can I animate while swipe?

I want to animate some objects (UIImage) while transitioning. Here's an example.
If the transition is across UIViewController, I can just use Hero library. Is there any way I can achieve it here?
img_0124

An ideal solution is that I assign the same id to two images in different slides, and it animates while sliding to its new position.

How to style the images

I am trying to upload new images and I have to change the size of images. How it can be done?
Please Help!

SwiftyOnboardPage isn't setup correctly if the view isn't fullscreen.

This is because, the container view's x & y are shifted, according to the non-fullscreen view's x & y.

Steps to reproduce:

  1. In the example project's use 'Storyboard Example View Controller'
  2. Adjust the view that is connected to the code, and shrink in size.

Screenshot 2019-11-17 at 10 16 39

  1. Try running, and find that the customPage is also shifted wrt the view's x & y.

Crash when background color set to "black" using delegate

If you pass "black" background color using a delegate it will crash. However it will not crash if I create black color like this (UIColor.init(red: 0.0, green: 0.0, blue: 0.0, alpha: 1.0)).

func swiftyOnboardBackgroundColorFor(_ swiftyOnboard: SwiftyOnboard, atIndex index: Int) -> UIColor? {
   return UIColor.black //This will crash. 🔥
}

SwiftyOnboardPage not showing

the code is calling
func swiftyOnboardPageForIndex(_ swiftyOnboard: SwiftyOnboard, index: Int) -> SwiftyOnboardPage? {

but SwiftyOnboardPage is not showing

Title not fitting completely in label

I cannot fit more than 2 lines of text to the SwiftyOnboardPage title label. Is there a way to get more lines? numberOfLines is set to 0 (auto) originally and I tried to manually set it to 0 and 3. I also tried to call sizeToFit() and set adjustsFontSizeToFitWidth = true. If it matters I have manually set a custom font with size of 22 and I am testing on iPhone 6 Plus simulator.

Use UView instead of SwiftyOnboardPage

SwiftyOnboardDataSourceprotocol have the method swiftyOnboardPageForIndexreturning a SwiftyOnboardPage.

This is a huge limitation to SwiftyOnboard customisation. Please consider returning UIView instead of SwiftyOnboardPage .

Its not Fullscreen

I create view controller but its not fullscreen in iphone plus! how should I make it fullscreen?

screen shot 2017-12-14 at 9 12 40 pm

Scroll vertical with navigation bar

Hello,

The scroll worked perfectly until i added a navigation controller and then a navigation bar. Now my page is scrolling vertically.

Before navigation bar
spotmeals presentation ios

After navigation bar
spotmeals presentation ios bug

Seems like the height of navigation bar is added to the scroll height of content.

Regards,

No such module 'SwiftyOnboard' in Xcode 9

Hi guys, why did I get this error No such module 'SwiftyOnboard' in Xcode 9? I'm installing SwiftyOnboard using pod and import SwiftyOnboard in ViewController . Thanks in advance

Overlay cannot be configured as wanted

On current version there is no way to modify overlay's elements, i.e. continueButton and skipButton.

Settings made in swiftyOnboardViewForOverlay are replaced by inner function set(style:) and overlay is not accessible outside the file.

swiftyOnboardOverlayForPositioncan be use but is not call at init so changes dot not show on the initial display: a user action must occur for this method to be called.

Minimum deployment target error

On import SwiftyOnboardan error occur: Module file's minimum deployment target is iOS10.2 v10.2.

Installation by Carthage.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.