objective c - How would I begin to replicate the custom view controller transition Apple uses as the default in iOS 7? -


using ios 7's custom view controller transitions, want achieve visual effect similar apple's default view controller transition in ios 7.

(the 1 can slide pop view controller off stack sliding left right, top view controller slides off top of other shadow , navigation bar shifts.)

enter image description here

i'm having great deal of difficulty implementing this, though. of tutorials on custom view controllers go different effects default in order show api capable off, want replicate one.

in subclass implementing <uiviewcontrolleranimatedtransitioning> have following code interactive animation:

- (void)animatetransition:(id<uiviewcontrollercontexttransitioning>)transitioncontext {     uiviewcontroller* toviewcontroller = [transitioncontext viewcontrollerforkey:uitransitioncontexttoviewcontrollerkey];     uiviewcontroller* fromviewcontroller = [transitioncontext viewcontrollerforkey:uitransitioncontextfromviewcontrollerkey];      [transitioncontext.containerview addsubview:toviewcontroller.view];     [transitioncontext.containerview addsubview:fromviewcontroller.view];      fromviewcontroller.view.layer.shadowoffset = cgsizemake(0.0, 0.0);     fromviewcontroller.view.layer.shadowcolor = [uicolor blackcolor].cgcolor;     fromviewcontroller.view.layer.shadowradius = 5.0;     fromviewcontroller.view.layer.shadowopacity = 0.5;      [uiview animatewithduration:[self transitionduration:transitioncontext] delay:0.0 options:uiviewanimationoptioncurvelinear animations:^{         cgrect newframe = fromviewcontroller.view.frame;         newframe.origin.x = cgrectgetwidth(fromviewcontroller.view.bounds);          fromviewcontroller.view.frame = newframe;     } completion:^(bool finished) {         [transitioncontext completetransition:!transitioncontext.transitionwascancelled];     }]; } 

however shadow code makes lag tremendously (even if use new snapshot methods) , cannot figure out how manipulate navigation bar @ all.

has tried similar , able provide sample code?

sample project testing if you'd like: http://cl.ly/0b3q1b390x0d

credit objc.io base code.

setting shadowpath increases performance of shadow.

just add in animatetransition: method after have set shadow properties. avoids expensive offscreen rendering shadow causes.

[fromviewcontroller.view.layer setshadowpath:[[uibezierpath bezierpathwithrect:fromviewcontroller.view.bounds] cgpath]]; 

i downloaded sample project , did that, stutter gone.

some info on here.

edit:

the answer manipulating navigation bar animation doesn't seem can. in order need reimplement own navigationcontroller-type class scratch. transition animation navigation bar done internally container view controller (the uinavigationcontroller) , not surfaced anywhere in code.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -