Mimic UIAlertController show animation - ios

So I created my own custom UIView that looks like an alert, and now I want to add show and hide animations.
I want to mimic Apples default animations for the AlertController. The dismissal is an simple fade animation, however I'm not sure how to articulate the show animation, it's almost like a fade in mixed with a shrink.
Anyways if anybody know how to recreate it I'd really appreciate it.
This is my final result:
This gif is doing it no justice but it's very similar to UIAlertControllers animations.
-(void)alerterShowAnimation {
self.alpha = 0;
self.hidden = NO;
self.transform = CGAffineTransformMakeScale(1.2, 1.2);
[UIView animateWithDuration:0.3 animations:^{
self.alpha = 1.0f;
self.containerView.backgroundColor = [UIColor colorWithWhite:0.0 alpha:0.5];
}];
[UIView animateWithDuration:0.2 delay:0 options:UIViewAnimationOptionCurveEaseIn animations:^{
self.transform = CGAffineTransformIdentity;
} completion:nil];
}

Instead of UIView animation, try using the core animation.
I have created a simple UIView with grey background, and added the animation below:
- (void)addAlertPopUpAnimationWithBeginTime:(CFTimeInterval)beginTime andFillMode:(NSString *)fillMode andRemoveOnCompletion:(BOOL)removedOnCompletion completion:(void (^)(BOOL finished))completionBlock
{
CAMediaTimingFunction *linearTiming = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
if (completionBlock)
{
CABasicAnimation *representativeAnimation = [CABasicAnimation animationWithKeyPath:#"not.a.real.key"];
representativeAnimation.duration = 0.200;
representativeAnimation.delegate = self;
[self.layer addAnimation:representativeAnimation forKey:#"AlertPopUp"];
}
CAKeyframeAnimation *proPicOpacityAnimation = [CAKeyframeAnimation animationWithKeyPath:#"opacity"];
proPicOpacityAnimation.duration = 0.200;
proPicOpacityAnimation.values = #[#(0.000), #(0.525), #(1.000)];
proPicOpacityAnimation.keyTimes = #[#(0.000), #(0.500), #(1.000)];
proPicOpacityAnimation.timingFunctions = #[linearTiming, linearTiming];
proPicOpacityAnimation.beginTime = beginTime;
proPicOpacityAnimation.fillMode = fillMode;
proPicOpacityAnimation.removedOnCompletion = removedOnCompletion;
[[self layer] addAnimation:proPicOpacityAnimation forKey:#"alertPopUp_Opacity"];
CAKeyframeAnimation *proPicScaleXAnimation = [CAKeyframeAnimation animationWithKeyPath:#"transform.scale.x"];
proPicScaleXAnimation.duration = 0.200;
proPicScaleXAnimation.values = #[#(0.304), #(0.345), #(0.300)];
proPicScaleXAnimation.keyTimes = #[#(0.000), #(0.500), #(1.000)];
proPicScaleXAnimation.timingFunctions = #[linearTiming, linearTiming];
proPicScaleXAnimation.beginTime = beginTime;
proPicScaleXAnimation.fillMode = fillMode;
proPicScaleXAnimation.removedOnCompletion = removedOnCompletion;
[[self layer] addAnimation:proPicScaleXAnimation forKey:#"alertPopUp_ScaleX"];
CAKeyframeAnimation *proPicScaleYAnimation = [CAKeyframeAnimation animationWithKeyPath:#"transform.scale.y"];
proPicScaleYAnimation.duration = 0.200;
proPicScaleYAnimation.values = #[#(0.381), #(0.435), #(0.389)];
proPicScaleYAnimation.keyTimes = #[#(0.000), #(0.500), #(1.000)];
proPicScaleYAnimation.timingFunctions = #[linearTiming, linearTiming];
proPicScaleYAnimation.beginTime = beginTime;
proPicScaleYAnimation.fillMode = fillMode;
proPicScaleYAnimation.removedOnCompletion = removedOnCompletion;
[[self layer] addAnimation:proPicScaleYAnimation forKey:#"alertPopUp_ScaleY"];
CAKeyframeAnimation *proPicTranslationXAnimation = [CAKeyframeAnimation animationWithKeyPath:#"transform.translation.x"];
proPicTranslationXAnimation.duration = 0.200;
proPicTranslationXAnimation.values = #[#(0.000), #(0.194), #(0.683)];
proPicTranslationXAnimation.keyTimes = #[#(0.000), #(0.500), #(1.000)];
proPicTranslationXAnimation.timingFunctions = #[linearTiming, linearTiming];
proPicTranslationXAnimation.beginTime = beginTime;
proPicTranslationXAnimation.fillMode = fillMode;
proPicTranslationXAnimation.removedOnCompletion = removedOnCompletion;
[[self layer] addAnimation:proPicTranslationXAnimation forKey:#"alertPopUp_TranslationX"];
CAKeyframeAnimation *proPicTranslationYAnimation = [CAKeyframeAnimation animationWithKeyPath:#"transform.translation.y"];
proPicTranslationYAnimation.duration = 0.200;
proPicTranslationYAnimation.values = #[#(0.000), #(11.242), #(0.581)];
proPicTranslationYAnimation.keyTimes = #[#(0.000), #(0.500), #(1.000)];
proPicTranslationYAnimation.timingFunctions = #[linearTiming, linearTiming];
proPicTranslationYAnimation.beginTime = beginTime;
proPicTranslationYAnimation.fillMode = fillMode;
proPicTranslationYAnimation.removedOnCompletion = removedOnCompletion;
[[self layer] addAnimation:proPicTranslationYAnimation forKey:#"alertPopUp_TranslationY"];
}
- (void)addAlertPopUpAnimationWithCompletion:(void (^)(BOOL finished))completionBlock
{
[self addAlertPopUpAnimationWithBeginTime:0 andFillMode:kCAFillModeBoth andRemoveOnCompletion:NO completion:completionBlock];
}
When you want to add animations, call right after you add your view as subview:
You need to subclass the UIView and put the code in there.
Later you can call:
[_yourView addAlertPopUpAnimationWithCompletion:^(BOOL finished) {
//do your stuff after animation is finished
}];
The animation looks like this:

Related

Mix CABasicAnimation with CGAffineTransform animation

I need to rotate an UIImageView continuously. To do this I found this code :
if ([self.image.layer animationForKey:#"SpinAnimation"] == nil) {
CABasicAnimation* animation = [CABasicAnimation animationWithKeyPath:#"transform.rotation.z"];
animation.fromValue = [NSNumber numberWithFloat:0.0f];
animation.toValue = [NSNumber numberWithFloat: 2 * M_PI];
animation.duration = 90.0f;
animation.repeatCount = INFINITY;
[self.image.layer addAnimation:animation forKey:#"SpinAnimation"];
}
Then, I need to make a transform translation on the image view, animating it. If I do this :
CGAffineTransform transform = self.image.transform;
transform = CGAffineTransformTranslate(transform, 0, 350);
[UIView animateWithDuration:1.0f animations:^{
[self.view layoutIfNeeded];
self.image.transform = transform;
} completion:^(BOOL finished) {
self.isMiddleViewOpened = YES;
}];
When the animation is performed, the image float all around the view before arriving to the end point of the translation.
Thanks ☺️
EDIT
I have issue because in my second transform I edit only the y value, but the image doesn't move only on y axis. If you try this code, you'll see the issue
There is no way to mix both animations, you can use Core animation to do all your animation stuff.
I use this in my splash screen to rotate four image blocks and combine them into one in the end.
The animation would like this:
Code for one image block: Top left block , I call it 00 block
- (void)addSplashScreenAnimationWithCompletion:(void (^)(BOOL finished))completionBlock
{
[self addSplashScreenAnimationWithBeginTime:0 andFillMode:kCAFillModeBoth andRemoveOnCompletion:NO completion:completionBlock];
}
- (void)addSplashScreenAnimationWithBeginTime:(CFTimeInterval)beginTime andFillMode:(NSString *)fillMode andRemoveOnCompletion:(BOOL)removedOnCompletion completion:(void (^)(BOOL finished))completionBlock
{
CAMediaTimingFunction *linearTiming = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
if (completionBlock)
{
CABasicAnimation *representativeAnimation = [CABasicAnimation animationWithKeyPath:#"not.a.real.key"];
representativeAnimation.duration = 8.500; //your duration
representativeAnimation.delegate = self;
[self.layer addAnimation:representativeAnimation forKey:#"SplashScreen"];
}
CAKeyframeAnimation *_00RotationAnimation = [CAKeyframeAnimation animationWithKeyPath:#"transform.rotation.z"];
_00RotationAnimation.duration = 8.500;
_00RotationAnimation.values = #[#(0.000), #(18.829), #(18.829)];
_00RotationAnimation.keyTimes = #[#(0.000), #(0.353), #(1.000)];
_00RotationAnimation.timingFunctions = #[linearTiming, linearTiming];
_00RotationAnimation.beginTime = beginTime;
_00RotationAnimation.fillMode = fillMode;
_00RotationAnimation.removedOnCompletion = removedOnCompletion;
CAKeyframeAnimation *_00OpacityAnimation = [CAKeyframeAnimation animationWithKeyPath:#"opacity"];
_00OpacityAnimation.duration = 8.500;
_00OpacityAnimation.values = #[#(0.000), #(0.497), #(0.553), #(0.759), #(0.921), #(1.000), #(0.642), #(0.341), #(0.000), #(0.000)];
_00OpacityAnimation.keyTimes = #[#(0.000), #(0.059), #(0.118), #(0.176), #(0.235), #(0.353), #(0.471), #(0.647), #(0.765), #(1.000)];
_00OpacityAnimation.timingFunctions = #[linearTiming, linearTiming, linearTiming, linearTiming, linearTiming, linearTiming, linearTiming, linearTiming, linearTiming];
_00OpacityAnimation.beginTime = beginTime;
_00OpacityAnimation.fillMode = fillMode;
_00OpacityAnimation.removedOnCompletion = removedOnCompletion;
CAKeyframeAnimation *_00ScaleXAnimation = [CAKeyframeAnimation animationWithKeyPath:#"transform.scale.x"];
_00ScaleXAnimation.duration = 8.500;
_00ScaleXAnimation.values = #[#(0.600), #(0.600), #(1.187), #(1.187)];
_00ScaleXAnimation.keyTimes = #[#(0.000), #(0.353), #(0.765), #(1.000)];
_00ScaleXAnimation.timingFunctions = #[linearTiming, linearTiming, linearTiming];
_00ScaleXAnimation.beginTime = beginTime;
_00ScaleXAnimation.fillMode = fillMode;
_00ScaleXAnimation.removedOnCompletion = removedOnCompletion;
CAKeyframeAnimation *_00ScaleYAnimation = [CAKeyframeAnimation animationWithKeyPath:#"transform.scale.y"];
_00ScaleYAnimation.duration = 8.500;
_00ScaleYAnimation.values = #[#(0.688), #(0.688), #(1.359), #(1.359)];
_00ScaleYAnimation.keyTimes = #[#(0.000), #(0.353), #(0.765), #(1.000)];
_00ScaleYAnimation.timingFunctions = #[linearTiming, linearTiming, linearTiming];
_00ScaleYAnimation.beginTime = beginTime;
_00ScaleYAnimation.fillMode = fillMode;
_00ScaleYAnimation.removedOnCompletion = removedOnCompletion;
CAKeyframeAnimation *_00TranslationXAnimation = [CAKeyframeAnimation animationWithKeyPath:#"transform.translation.x"];
_00TranslationXAnimation.duration = 8.500;
_00TranslationXAnimation.values = #[#(0.000), #(107.423), #(211.936), #(211.936)];
_00TranslationXAnimation.keyTimes = #[#(0.000), #(0.353), #(0.765), #(1.000)];
_00TranslationXAnimation.timingFunctions = #[linearTiming, linearTiming, linearTiming];
_00TranslationXAnimation.beginTime = beginTime;
_00TranslationXAnimation.fillMode = fillMode;
_00TranslationXAnimation.removedOnCompletion = removedOnCompletion;
CAKeyframeAnimation *_00TranslationYAnimation = [CAKeyframeAnimation animationWithKeyPath:#"transform.translation.y"];
_00TranslationYAnimation.duration = 8.500;
_00TranslationYAnimation.values = #[#(0.000), #(390.498), #(476.237), #(476.237)];
_00TranslationYAnimation.keyTimes = #[#(0.000), #(0.353), #(0.765), #(1.000)];
_00TranslationYAnimation.timingFunctions = #[linearTiming, linearTiming, linearTiming];
_00TranslationYAnimation.beginTime = beginTime;
_00TranslationYAnimation.fillMode = fillMode;
_00TranslationYAnimation.removedOnCompletion = removedOnCompletion;
}
The above method contains series of animations like rotating, opacity changin,,scaling along x and y axis,translating along x and y axis.
You need to subclass the UIImageView or UIView and put the animation in there.
You can call the above method like:
//Here _splashView can be UIView or UIImageView
[_splashView addSplashScreenAnimationWithCompletion:^(BOOL finished) {
//Do your stuff after animation is completed
}];
You can use repeatCount for CAKeyFrameAnimation too, and you should give HUGE_VALF to get the infinity time rotation.

"Glitch" during UIView Intro CAAnimation

I'm trying to add an Animation to a UIView. The objective of the animation is to "animate" the View appearing on screen (instead of just appearing there).
The animation is all size scaling: start from 5%, go up to 120% and then very quickly back to 100% of the regular scale.
My issue is that the full scale UIView appears very quickly, before the animation starts.
Here's the code:
UIView * myView = [[UIView alloc] initWithFrame:someFrame];
[self.view addSubview:myView];
[self initialAnimationFor:myView];
-(void) initialAnimationFor:(UIView*)pView {
const CFTimeInterval firstDuration = 0.75f;
const CFTimeInterval secondDuration = 0.025f;
const float initialValue = 0.05f;
const float middleValue = 1.20f;
CABasicAnimation * firstAnimation = [CABasicAnimation animationWithKeyPath:#"transform.scale"];
firstAnimation.duration = firstDuration;
firstAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
firstAnimation.fromValue = [NSNumber numberWithFloat:initialValue];
firstAnimation.toValue = [NSNumber numberWithFloat:middleValue];
CABasicAnimation * secondAnimation = [CABasicAnimation animationWithKeyPath:#"transform.scale"];
secondAnimation.duration = secondDuration;
secondAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
secondAnimation.fromValue = [NSNumber numberWithFloat:middleValue];
secondAnimation.toValue = [NSNumber numberWithFloat:1.0f];
CAAnimationGroup *animationGroup = [CAAnimationGroup new];
animationGroup.duration = firstDuration + secondDuration;
animationGroup.animations = #[firstAnimation, secondAnimation];
[pView.layer addAnimation:animationGroup forKey:nil];
}
Any ideas? Thanks!
I would do a different technique and use chained UIView block animations, like this:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
UIView *myView = [[UIView alloc] initWithFrame:CGRectMake(40, 40, 200, 200)];
myView.backgroundColor = [UIColor redColor];
[self initialAnimationFor:myView];
}
- (void)initialAnimationFor:(UIView*)pView {
pView.transform = CGAffineTransformMakeScale(0.05f, 0.05f);
if (pView.superview == nil) {
[self.view addSubview:pView];
}
[UIView
animateWithDuration:0.75f
animations:^{
pView.transform = CGAffineTransformMakeScale(1.20f, 1.20f);
}
completion:^(BOOL finished) {
[UIView
animateWithDuration:0.25f // <-- Your old value of 0.025f makes the animation VERY quick
animations:^{
pView.transform = CGAffineTransformIdentity;
}
];
}
];
}
With this setup, you get the "grow to slightly larger than 100% and then 'settle' to 100%" effect.
Is this a workable solution?

UIViewController Animated Transitioning fails in iOS8

I've got a custom UIViewController transition -- in iOS7, it works perfectly fine.
However, when run on iOS 8, I'm experiencing issues. Specifically, when the presented view controller is dismissed, the original view controller's view disappears entirely - leaving me with a completely blank screen. Here is my code:
#implementation DDCardTransition
- (NSTimeInterval)transitionDuration:(id <UIViewControllerContextTransitioning>)transitionContext {
return 0.5f;
}
- (void)animateTransition:(id <UIViewControllerContextTransitioning>)transitionContext {
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
CGRect endFrame = self.destinationFrame;
if (self.presenting) {
fromViewController.view.userInteractionEnabled = NO;
toViewController.view.layer.cornerRadius = 6.0f;
UIView *tintAdjustmentView = [UIView new];
tintAdjustmentView.frame = fromViewController.view.frame;
tintAdjustmentView.backgroundColor = [UIColor blackColor];
tintAdjustmentView.alpha = 0.f;
[transitionContext.containerView addSubview:fromViewController.view];
[transitionContext.containerView addSubview:tintAdjustmentView];
[transitionContext.containerView addSubview:toViewController.view];
CGRect startFrame = endFrame;
startFrame.origin.y += [UIScreen mainScreen].bounds.size.height;
toViewController.view.frame = startFrame;
[CATransaction begin];
[CATransaction setCompletionBlock:^{
[transitionContext completeTransition:YES];
}];
CABasicAnimation *frameAnimation = [CABasicAnimation animationWithKeyPath:#"position"];
frameAnimation.timingFunction = [CAMediaTimingFunction functionWithControlPoints:0.1f :0.8f :0.0 :1.0];
frameAnimation.duration = [self transitionDuration:transitionContext];
frameAnimation.fromValue = [NSValue valueWithCGPoint:CGPointMake(CGRectGetMidX(startFrame), CGRectGetMidY(startFrame))];
frameAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(CGRectGetMidX(endFrame), CGRectGetMidY(endFrame))];
toViewController.view.layer.position = [frameAnimation.toValue CGPointValue];
[toViewController.view.layer addAnimation:frameAnimation forKey:#"position"];
CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:#"opacity"];
opacityAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
opacityAnimation.duration = 0.3f;
opacityAnimation.fromValue = #(0.f);
opacityAnimation.toValue = #(0.5f);
tintAdjustmentView.layer.opacity = [opacityAnimation.toValue floatValue];
[tintAdjustmentView.layer addAnimation:opacityAnimation forKey:#"opacity"];
[CATransaction commit];
}
else {
toViewController.view.userInteractionEnabled = YES;
UIView *tintAdjustmentView = [UIView new];
tintAdjustmentView.frame = toViewController.view.frame;
tintAdjustmentView.backgroundColor = [UIColor blackColor];
tintAdjustmentView.alpha = 0.5f;
[transitionContext.containerView addSubview:toViewController.view];
[transitionContext.containerView addSubview:tintAdjustmentView];
[transitionContext.containerView addSubview:fromViewController.view];
endFrame.origin.y += [UIScreen mainScreen].bounds.size.height;
[UIView animateWithDuration:[self transitionDuration:transitionContext] animations:^{
fromViewController.view.frame = endFrame;
tintAdjustmentView.alpha = 0.f;
} completion:^(BOOL finished) {
[transitionContext completeTransition:YES];
}];
}
}
#end
Any idea why this no longer works in iOS8?
Thanks!
the following code work fine in xcode GM:
func animateTransition(transitionContext: UIViewControllerContextTransitioning!) {
let fromViewController = transitionContext.viewControllerForKey(UITransitionContextToViewControllerKey)
let fromViewControllerView = transitionContext.viewForKey(UITransitionContextFromViewKey)
let containerView = transitionContext.containerView()
fromViewControllerView?.frame = transitionContext.finalFrameForViewController(fromViewController!)
fromViewControllerView?.frame.origin.y = containerView.bounds.height
containerView.addSubview(fromViewControllerView!)
UIView.animateWithDuration(transitionDuration(transitionContext),
delay: 0.0,
options: .AllowUserInteraction,
animations: {
fromViewControllerView!.center.y = containerView.bounds.size.height/2
},
completion: { (completed: Bool) -> Void in
transitionContext.completeTransition(completed)
}
)
}

Can I rotate UIImage around the centre with animation?

I want to rotate image in circular animation. How can I do it in a simple way?
I know it is not difficult but I'm new to iOS.
Can anybody tell me right code ?
its my solution:
- (void)startAnimation
{
[UIView animateWithDuration:.4 delay:0 options:UIViewAnimationOptionCurveLinear animations:^{
[self.loadingRingImageView setTransform:CGAffineTransformRotate(self.loadingRingImageView.transform, M_SQRT2)];
} completion:^(BOOL finished) {
if (finished)
{
[self startAnimation];
}
}];
}
[[self.<imageviewinstance> layer] addAnimation:[self rotationAnimation] forKey:nil];
Add the animation as above and the below is the animation code.
- (CABasicAnimation *)rotationAnimation
{
CABasicAnimation *rotAnim = [CABasicAnimation animationWithKeyPath:#"position"];
[rotAnim setFromValue:[NSValue valueWithCGPoint:CGPointMake(100.0, 400.0)]];
rotAnim.toValue = [NSValue valueWithCGPoint:CGPointMake(300.0, 150.0)];
// rotAnim.duration = 5.0;
rotAnim.autoreverses = YES;
// rotAnim.repeatCount = HUGE_VAL;
rotAnim.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
return rotAnim;
}
if the above is not worked use this
- (CABasicAnimation *)rotationAnimation
{
CABasicAnimation *move = [CABasicAnimation animationWithKeyPath:#"transform.rotation" ];
move.delegate = self;
[move setFromValue:[NSNumber numberWithFloat:0]];
[move setToValue:[NSNumber numberWithFloat:50]];
[move setDuration:10.0f];
move.autoreverses = YES;
}
the answer of question i was wondering is ->
UIImageView *imageViewForAnimation = [[UIImageView alloc] initWithImage:imageToAnimate];
imageViewForAnimation.alpha = 1.0f;
CGRect imageFrame = imageViewForAnimation.frame;
//Your image frame.origin from where the animation need to get start
CGPoint viewOrigin = imageViewForAnimation.frame.origin;
viewOrigin.y = viewOrigin.y + imageFrame.size.height / 2.0f;
viewOrigin.x = viewOrigin.x + imageFrame.size.width / 2.0f;
imageViewForAnimation.frame = imageFrame;
imageViewForAnimation.layer.position = viewOrigin;
[self.view addSubview:imageViewForAnimation];
// Set up fade out effect
CABasicAnimation *fadeOutAnimation = [CABasicAnimation animationWithKeyPath:#"opacity"];
[fadeOutAnimation setToValue:[NSNumber numberWithFloat:0.3]];
fadeOutAnimation.fillMode = kCAFillModeForwards;
fadeOutAnimation.removedOnCompletion = NO;
// Set up scaling
CABasicAnimation *resizeAnimation = [CABasicAnimation animationWithKeyPath:#"bounds.size"];
[resizeAnimation setToValue:[NSValue valueWithCGSize:CGSizeMake(40.0f, imageFrame.size.height * (40.0f / imageFrame.size.width))]];
resizeAnimation.fillMode = kCAFillModeForwards;
resizeAnimation.removedOnCompletion = NO;
// Set up path movement
CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:#"position"];
pathAnimation.calculationMode = kCAAnimationPaced;
pathAnimation.fillMode = kCAFillModeForwards;
pathAnimation.removedOnCompletion = NO;
//Setting Endpoint of the animation
CGPoint endPoint = CGPointMake(480.0f - 30.0f, 40.0f);
//to end animation in last tab use
//CGPoint endPoint = CGPointMake( 320-40.0f, 480.0f);
CGMutablePathRef curvedPath = CGPathCreateMutable();
CGPathMoveToPoint(curvedPath, NULL, viewOrigin.x, viewOrigin.y);
CGPathAddCurveToPoint(curvedPath, NULL, endPoint.x, viewOrigin.y, endPoint.x, viewOrigin.y, endPoint.x, endPoint.y);
pathAnimation.path = curvedPath;
CGPathRelease(curvedPath);
CAAnimationGroup *group = [CAAnimationGroup animation];
group.fillMode = kCAFillModeForwards;
group.removedOnCompletion = NO;
[group setAnimations:[NSArray arrayWithObjects:fadeOutAnimation, pathAnimation, resizeAnimation, nil]];
group.duration = 0.7f;
group.delegate = self;
[group setValue:imageViewForAnimation forKey:#"imageViewBeingAnimated"];
[imageViewForAnimation.layer addAnimation:group forKey:#"savingAnimation"];

UIViewControllerAnimatedTransitioning in iOS7 - viewWillAppear not called

I'm trying to get the hang of the new viewController animations in ios7 but I am encountering a road bump when trying to use core animation.
Im finding that after the transition has completed, the controller of the 'to view' does not seem to be receiving the typical view lifecycle methods, i.e. viewWillAppear and viewDidAppear. I'm calling completeTransition: but that doest seem to be enough -- is this typical behavior? Or am I doing something wrong? here is my code:
-(void)executeDismissalAnimation:(id<UIViewControllerContextTransitioning>)transitionContext{
UIView *inView = [transitionContext containerView];
UIViewController *toViewController = [transitionContext viewControllerForKey:UITransitionContextToViewControllerKey];
UIViewController *fromViewController = [transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey];
toViewController.view.hidden = NO;
[CATransaction begin];
[CATransaction setCompletionBlock:^{
[fromViewController.view removeFromSuperview];
[transitionContext completeTransition:YES];
}];
CGFloat duration = 0.4f;
CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:#"transform.scale"];
scaleAnimation.values = [self floatValuesFromValue:1.f toValue:1.5f withEasingFunction:ExponentialEaseInOut];
scaleAnimation.duration = duration;
scaleAnimation.fillMode = kCAFillModeForwards;
scaleAnimation.removedOnCompletion = YES;
[fromViewController.view.layer addAnimation:scaleAnimation forKey:nil];
CAKeyframeAnimation *alphaAnimation = [CAKeyframeAnimation animationWithKeyPath:#"opacity"];
alphaAnimation.values = [self floatValuesFromValue:1.f toValue:0.f withEasingFunction:LinearInterpolation];
alphaAnimation.duration = duration*2;
alphaAnimation.fillMode = kCAFillModeForwards;
alphaAnimation.removedOnCompletion = YES;
[fromViewController.view.layer addAnimation:alphaAnimation forKey:nil];
CAKeyframeAnimation *scaleAnimationB = [CAKeyframeAnimation animationWithKeyPath:#"transform.scale"];
scaleAnimationB.values = [self floatValuesFromValue:0.6f toValue:1.0f withEasingFunction:ExponentialEaseInOut];
scaleAnimationB.duration = duration;
scaleAnimationB.beginTime = CACurrentMediaTime()+0.3;
scaleAnimationB.fillMode = kCAFillModeForwards;
scaleAnimationB.removedOnCompletion = NO;
[toViewController.view.layer addAnimation:scaleAnimationB forKey:nil];
CAKeyframeAnimation *alphaAnimationB = [CAKeyframeAnimation animationWithKeyPath:#"opacity"];
alphaAnimationB.values = [self floatValuesFromValue:0.5f toValue:1.f withEasingFunction:LinearInterpolation];
alphaAnimationB.duration = duration;
alphaAnimationB.beginTime = CACurrentMediaTime()+0.3;
alphaAnimationB.fillMode = kCAFillModeForwards;
alphaAnimationB.removedOnCompletion = NO;
[toViewController.view.layer addAnimation:alphaAnimationB forKey:nil];
[CATransaction commit];
}

Resources