Custom transitions

To add a custom transition, you just have to extend the SPTransitions class using a category, and add your custom transition. The name of the transition method will be the name that you have to use when you create the tween. Here is a sample:

SPTransitions+CustomTransitions.h
#import <Foundation/Foundation.h>
 
#define SPCT_TRANSITION_EASE_OUT_ELASTIC_SHORT @"easeOutElasticShort"
 
@interface SPTransitions (CustomTransitions)
 
+ (float)easeOutElasticShort:(float)ratio;
 
@end
SPTransitions+CustomTransitions.m
#import "SPTransitions+CustomTransitions.h"
 
@implementation SPTransitions (CustomTransitions)
 
+ (float)easeOutElasticShort:(float)ratio
{
    if (ratio == 0.0f || ratio == 1.0f) return ratio;
    else
    {
        float bounce_factor = -5.0f;
        float p = 0.6f;
        float s = p / 4.0f;
        return powf(2.0f, bounce_factor*ratio) * sinf((ratio-s)*TWO_PI/p) + 1.0f;
    }
}
 
@end
  tutorials/custom_transitions.txt · Last modified: 2013/03/05 10:19 (external edit)
 
Powered by DokuWiki