Latest 1.0.0
Homepage https://github.com/adamszeremeta/TweeningUIPageViewController
License MIT
Platforms ios 8.0
Authors

Platform License

Extended UIPageViewController with background color tweening

demo

Table of contents

Features

  • animated background color tweening between controllers

Installation

The prefered way is to use CococaPods.

use_frameworks!
pod 'TweeningUIPageViewController', '~> 1.0.0'

If you can’t use CocoaPods for some reason, then grab the files in TweeningUIPageViewController/ and put it in your project.

Usage

Add or replace existing implementation from UIPageViewController to TweeningPageViewController and implement TweeningPageViewControllerDelegate protocol.
Below you can find some code snippets. You can also checkout full example project.

Set TweeningPageViewControllerDelegate:


let pageController = ... (reference to your TweeningPageViewController instance)
pageController.tweeningDelegate = self

Implement TweeningPageViewControllerDelegate required methods:


// MARK: TweeningUIPageViewControllerDelegate

func tweeningPageViewController(tweeningController:TweeningPageViewController, backgroundColorForControllerBeforeController viewController:UIViewController?) -> UIColor? {

    if let pageController = viewController as? MyPageViewController {

        let previousIndex = pageController.controllerIndex - 1
        if previousIndex >= 0 && previousIndex < self.backgroundColors.count {

            return self.backgroundColors[previousIndex]
        }
    }

    return nil
}

func tweeningPageViewController(tweeningController:TweeningPageViewController, backgroundColorForCurrentController viewController:UIViewController?) -> UIColor? {

    if let pageController = viewController as? MyPageViewController {

        return self.backgroundColors[pageController.controllerIndex]
    }

    return nil
}

func tweeningPageViewController(tweeningController:TweeningPageViewController, backgroundColorForControllerAfterController viewController:UIViewController?) -> UIColor? {

    if let pageController = viewController as? MyPageViewController {

        let nextIndex = pageController.controllerIndex + 1
        if nextIndex >= 0 && nextIndex < self.backgroundColors.count {

            return self.backgroundColors[nextIndex]
        }
    }

    return nil
}

License

TweeningUIPageViewController is released under the MIT license.

Latest podspec

{
    "name": "TweeningUIPageViewController",
    "version": "1.0.0",
    "summary": "Extended UIPageViewController with background color tweening",
    "homepage": "https://github.com/adamszeremeta/TweeningUIPageViewController",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Adam Szeremeta": "[email protected]"
    },
    "source": {
        "git": "https://github.com/adamszeremeta/TweeningUIPageViewController.git",
        "tag": "1.0.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "TweeningUIPageViewController/*.swift"
}

Pin It on Pinterest

Share This