Git Product home page Git Product logo

introscreen's Introduction

IntroScreen

Version License Platform

A beautiful intro screen for iOS written in Swift.

How to use:

  1. Create an IntroDataSource like that:
struct MyIntroDataSource: IntroDataSource {
    
    let numberOfPages = 3
    
    // Set to true, if you want to fade out the last page color into black.
    let fadeOutLastPage: Bool = false
    
    func viewController(at index: Int) -> IntroPageViewController? {
        switch index {
        case 0:
            return DefaultIntroPageViewController(
                index: index,
                hue: 30/360,
                title: "First page",
                subtitle: "This is the first page.",
                image: UIImage(named: "first")!
            )
        case 1:
            return DefaultIntroPageViewController(
                index: index,
                hue: 60/360,
                title: "Second page",
                subtitle: "This is the second page.",
                image: UIImage(named: "second")!
            )
        case 2:
            return DefaultIntroPageViewController(
                index: index,
                hue: 90/360,
                title: "Third page",
                subtitle: "This is the third page.",
                image: UIImage(named: "third")!
            )
        default:
            return nil
        }
    }
}
  1. Create the IntroViewController using the data source:
let viewController = IntroViewController(dataSource: dataSource)

That's it! ๐Ÿ˜Ž

Customization

Of course you can also use a custom view controller for the pages. Just extend IntroPageViewController or use a UIViewController that implements IntroPage. Keep in mind that you have to give it a clear background, so that the colors are visible.

The colors use the HSV color model. So, you just provide the hue in your Intro Pages:

public protocol IntroPage: AnyObject {
    
    // ...
    
    /// The color hue between 0 & 1 for the HSV color.
    var hue: CGFloat { get }
}

You can change the saturation & brightness in the IntroViewController for all pages at the same time:

let viewController = IntroViewController(
  dataSource: dataSource,
  saturation: 0.85, 
  brightness: 0.9
)

If you want to navigate the pages programmatically (for example if you want to add buttons for this), you can use these methods:

introViewController.nextPage() // navigate forward
introViewController.previousPage() // navigate backwards

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

IntroScreen is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'IntroScreen'

Author

P1xelfehler, [email protected]

License

IntroScreen is available under the MIT license. See the LICENSE file for more info.

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.