Skip to content
Split82 edited this page Sep 28, 2010 · 5 revisions

Description

HMGLTransitions is set of Objective C classes which can animate few UIKit transitions in iOS ( > 3.0). This is not enhancement of standard animations. This animation works differently. All transitions are presented in UIView with CAEAGLLayer using OpenGL, which gives you absolute freedom in creating almost any animation. You can start using only transitions already created. Right now this four transitions are available: Switch3DTransition, FlipTransition, RotateTransition and ClothTransition (more comming). To perform transition animation HMGLTransitionManager singleton object is used.

UIView transitions:

You can create UIView transition animation in same manner as creating UIKit transition animations, except transition object must be set first.

	FlipTransition *transition = [[[FlipTransition alloc] init] autorelease]; // 1
	[[HMGLTransitionManager sharedTransitionManager] setTransition:transition]; // 2
	[[HMGLTransitionManager sharedTransitionManager] beginTransition:containerView]; // 3
	
	[view1 removeFromSuperview]; // 4
	[containerView addSubview:view2]; // 5
	
	[[HMGLTransitionManager sharedTransitionManager] commitTransition]; // 6
  1. First new transition object is created. You can implement your own object by subclassing HMGLTransition and implementing all of it's methods. Here FlipTransition object is used.
  2. Transition object is set
  3. Transition is initialized with containerView.
  4. view1 which should be a subview of containerView is removed from display hierarchy
  5. view2 is added as subview of containerView
  6. animation starts

UIViewController present / dismiss

Presenting and dismissing UIViewController is absolutely straight-forward.

	ClothTransition *transition = [[[ClothTransition alloc] init] autorelease]; // 1
	[[HMGLTransitionManager sharedTransitionManager] setTransition:transition]; // 2
	[[HMGLTransitionManager sharedTransitionManager] presentModalViewController:modalController onViewController:actualController]; // 3
  1. New transition object is created
  2. Transition object is set.
  3. UIViewController is presented. modalController is new UIViewController which we want to present and actualController is UIViewController which is active at the moment (usually it is self)

Creating HMGLTransition subclasses

The easiest way to create your own transition is start with Switch3DTransition and rewrite it. (More details soon).