ios - Can I set maximum alpha for CATransition? -
is possible adjust maximum alpha (opacity) in catransition
when views fade in , out?
what want looks modal segue. compared default modal segue, transition given catransition
«dramatic».
say have 2 views. a: view want transition from. b: view want transition to.
i want b come moving in bottom on a. use kcatransitionmovein
type, subtype kcatransitionfromtop
(which weird because b moving bottom, not top).
in default modal segue, works fine, , greyed out little. catransition
, totally black @ towards end of transition when b has moved 70% on 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 here.
after digging around more figured can't set maximum opacity / alpha catransition out of box.
so solved this:
//offset frame vc.view.frame = cgrectmake(0, cgrectgetheight(self.view.bounds), cgrectgetwidth(self.view.bounds), cgrectgetheight(self.view.bounds)); [uiview animatewithduration:5 animations:^{ //insert over/before root view instead of after [keywindow insertsubview:vc.view abovesubview:keywindow.rootviewcontroller.view]; vc.view.frame = cgrectmake(0, 0, cgrectgetwidth(self.view.bounds), cgrectgetheight(self.view.bounds)); keywindow.rootviewcontroller.view.alpha = 0.8; } completion:^(bool finished) { nslog(@"completed! can change rootviewcontroller etc.."); }];
Comments
Post a Comment