I'm not sure about creating a block-based method, but I've found that a fairly simple way to implement a custom easing function and still used block-based animations is to override the layer's addAnimation:(CAAnimation *)anim forKey:(NSString *)key
method and swap in a different easing function for whatever view you want to animate.
To start, subclass CALayer, and add the following method...
// CustomViewLayer.m
#import "CustomViewLayer.h"
@implementation CustomViewLayer
- (void)addAnimation:(CAAnimation *)anim forKey:(NSString *)key
{
if ([anim isKindOfClass:[CABasicAnimation class]]) {
// intercept the animation and insert your own easing function
int x1 = 0.250;
int y1 = 1.185;
int x2 = 0.210;
int y2 = 1.000;
CAMediaTimingFunction *func = [CAMediaTimingFunction functionWithControlPoints:x1 :y1 :x2 :y2];
anim.timingFunction = func;
}
[super addAnimation:anim forKey:key];
}
@end
In your view subclass, make sure you're returning the custom layer class...
// CustomView.m
#import "CustomView.h"
#import "CustomViewLayer.h"
@implementation CustomView
+ (Class)layerClass
{
return [CustomViewLayer class];
}
@end
Then, you can use the standard block-based animation methods such as...
[UIView animateWithDuration:0.3 animations:^{
[customView setFrame:newFrame];
}];
...and the custom easing function will be used. It may not solve all your problems, but it is easy to do and it still allows you to use block-based animations. Keep in mind, however, that the easing function will apply to any and all animations that are animated through the block-based methods. So if you want to animate the alpha property for example, but don't want to use the custom easing function, you will have to fiddle around with it or maybe come up with a different solution altogether.
Lastly, an awesome tool for easily creating and testing easing functions can be found here: http://matthewlein.com/ceaser/
-actionForKey:forLayer:
(or whatever it's called) to provide the correct animation whenever a property change is made from within the passed animation block... That's where I'd start anyway – Zilber