IntroScreen 1.3.0

IntroScreen 1.3.0

Maintained by P1xelfehler.



  • By
  • P1xelfehler

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.