/GC3DFlipTransitionStyleSegue

iBooks-style 3D flip transition animation rendered in OpenGL ES 2.0 and wrapped in a UIStoryboardSegue subclass

Primary LanguageObjective-C

GC3DFlipTransitionStyleSegue

iBooks-style 3D flip transition animation rendered in OpenGL ES 2.0 and wrapped in a UIStoryboardSegue subclass.

Segue in action (complete clip can be found on Youtube):

image

Comparison between iBooks and this segue class:

image

Features / Design

  • Uses OpenGL ES rendering instead of Core Animation for high performance (60 fps) and shader effects.
  • Uses GLKit to drastically reduce the amount of OpenGL ES 2.0 code (to write and maintain).
  • Inspired by Apple's 3D flip view controller transition animation, as found in iOS apps like iBooks, iTunes U and Podcasts.
  • Supports different screen sizes and screen orientations.
  • Quick and easy setup. See installation.

Requirements

GC3DFlipTransitionStyleSegue requires iOS 5.0 and above.

Installation

Add the source code to your project (and image file if you want to use it). Link your target against QuartzCore.framework, GLKit.framework and OpenGLES.framework.

CocoaPods support: pod 'GC3DFlipTransitionStyleSegue'

If you use this class in a non-ARC project, make sure you add the -fobjc-arc compiler flag for the implementation file.

Quick setup: Just set this class as a custom segue and it'll work right away.

image

Customization

To change the default texture on the side, change these macros:

#define IMAGE_NAME  @"wood"
#define IMAGE_TYPE  @"jpg"

Exposed in the header file are some customization properties:

- Depth

This property sets the depth (or thickness) of the 3D object.

@property (assign, nonatomic) float depth

Discussion

Depth value cannot be 0 (zero) as this will set the default value of 0.5 (kGC3DFlipTransitionStyle_iBooks). For a very small depth value use kGC3DFlipTransitionStyle_Horizontal.

There are three constant keys set in the header file:

extern float kGC3DFlipTransitionStyle_Horizontal

Very small depth like Apple's transition style animation UIModalTransitionStyleFlipHorizontal. To see how it looks like, take a look at the screenshot.

extern float kGC3DFlipTransitionStyle_iTunesU

Depth value set like the iTunes U app (bit smaller than iBooks).

extern float kGC3DFlipTransitionStyle_iBooks

Dept value set like the iBooks (and Podcasts) app. This is the default value.

- disableLightEffect

This property disables the light effect.

@property (assign, nonatomic) BOOL disableLightEffect

Discussion

Disabling the light effect allows the animation to mimic Apple's 3D flip transition animation. It does not have an effect on performance. Light effect is enabled by default. To see how it looks like, take a look at the screenshot.

- disableMultisampling

This property disables 4x multisampling anti-aliasing (4x MSAA).

@property (assign, nonatomic) BOOL disableMultisampling

Discussion

Multisampling improves image quality. It is enabled by default. Disable it for slightly better performance on older devices.

Example

This is an example on how to set the segue properties:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue isKindOfClass:[GC3DFlipTransitionStyleSegue class]])
    {
        GC3DFlipTransitionStyleSegue *flipSegue = (GC3DFlipTransitionStyleSegue *)segue;
        flipSegue.disableLightEffect = YES;
        flipSegue.disableMultisampling = YES;
        flipSegue.depth = kGC3DFlipTransitionStyle_iTunesU;
    }
}

Screenshots:

image

Todo

  • Add option to flip view controllers in opposite direction like Apple's Podcasts app.
  • Improve snapshot performance on the iPad.

License

This code is distributed under the terms and conditions of the zlib license.

Copyright (c) 2013 Glenn Chiu

This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.

Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions:

  1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.

  2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.

  3. This notice may not be removed or altered from any source distribution.