Is it possible to adjust the maximum alpha (opacity) in a CATransition
for when the views fade in and out?
What I want is something that looks like a modal segue. Compared to a default modal segue, the transition given by CATransition
is very «dramatic».
Say I have two views. A: the view I want to transition from. B: the view I want to transition to.
I want B to come moving in from the bottom over A. For this I use the kCATransitionMoveIn
type, with subtype kCATransitionFromTop
(which is weird because B is moving up from bottom, not top).
In the default modal segue, this works fine, and A is only greyed out a little. With CATransition
, A is totally black at towards the end of the transition when B has moved about 70% over A.
Code:
UIStoryboard *loginBoard = [UIStoryboard storyboardWithName:@"Login" bundle:nil];
UIViewController *vc = [loginBoard instantiateInitialViewController];
UIWindow *keyWindow = [[[UIApplication sharedApplication] delegate] window];
[keyWindow insertSubview:vc.view belowSubview:keyWindow.rootViewController.view];
CATransition *transition = [CATransition animation];
transition.duration = 0.5;
transition.type = kCATransitionMoveIn;
transition.subtype = kCATransitionFromTop;
[keyWindow.layer addAnimation:transition forKey:kCATransition];
[keyWindow.rootViewController.view removeFromSuperview];
keyWindow.rootViewController = vc;
The problem originates from here.