ios - Custom Transition Animation Causing Navigation Bar to Animate -
i implementing custom transition animation between view controllers, reason navigation bar getting animated along transition animation. somehow auto layout issue? i'm not sure how be. here code using display , dismiss view controllers custom transition.
i navigation bar not animated, ideas why happening?
-(void)animatetransition:(id<uiviewcontrollercontexttransitioning>)transitioncontext { // grab , view controllers context uiviewcontroller *fromviewcontroller = [transitioncontext viewcontrollerforkey:uitransitioncontextfromviewcontrollerkey]; uiviewcontroller *toviewcontroller = [transitioncontext viewcontrollerforkey:uitransitioncontexttoviewcontrollerkey]; if (self.presenting) { fromviewcontroller.view.userinteractionenabled = no; [transitioncontext.containerview addsubview:fromviewcontroller.view]; [transitioncontext.containerview addsubview:toviewcontroller.view]; int frameheight = fromviewcontroller.view.frame.size.height; cgrect startframe = fromviewcontroller.view.frame; startframe.origin.y = frameheight; toviewcontroller.view.frame = startframe; //create view same background color cover background on bounce effect uiview *bottomcover = [[uiview alloc]initwithframe:cgrectmake(0, startframe.size.height-30, startframe.size.width, 30)]; [bottomcover setbackgroundcolor:[uicolor colorwithred:0.956 green:0.962 blue:0.956 alpha:1]]; [transitioncontext.containerview insertsubview:bottomcover belowsubview:toviewcontroller.view]; __block cgrect endframe = toviewcontroller.view.frame; [uiview animatewithduration:[self transitionduration:transitioncontext] delay:0 usingspringwithdamping:.75 initialspringvelocity:1.0 options:uiviewanimationoptioncurveeasein animations:^{ endframe.origin.y = 0; toviewcontroller.view.frame = endframe; } completion:^(bool finished) { [bottomcover removefromsuperview]; toviewcontroller.view.frame = endframe; [transitioncontext completetransition:yes]; }]; } else { toviewcontroller.view.userinteractionenabled = yes; [transitioncontext.containerview addsubview:toviewcontroller.view]; [transitioncontext.containerview addsubview:fromviewcontroller.view]; cgrect endframe = toviewcontroller.view.frame; endframe.origin.y = 0; fromviewcontroller.view.frame = endframe; [uiview animatewithduration:[self transitionduration:transitioncontext] delay:0 usingspringwithdamping:.9 initialspringvelocity:1.0 options:uiviewanimationoptioncurveeasein animations:^{ int frameheight = toviewcontroller.view.frame.size.height; cgrect startframe = fromviewcontroller.view.frame; startframe.origin.y = frameheight; fromviewcontroller.view.frame = startframe; } completion:^(bool finished) { [transitioncontext completetransition:yes]; //because there bug in xcode apparently. [[uiapplication sharedapplication].keywindow addsubview:toviewcontroller.view]; }]; } }
Comments
Post a Comment