objective c - iOS custom animation to replace a subview -


i have app viewcontroller contains headerview, headerview container should hold other views. views inside headerview views want replace @ runtime animation. want oldview (which old content of headerview) slide out left , newview slide in right. i've included code below , log. slide in animation of newview works, oldview slides (0,0) coordinates, instead of (-headerview.bounds.size.width, 0) coordinates. kind of animation impossible, or isn't uiview animatewithduration made kind of animations? lot already.

the code:

//put frame @ right side of out bounds (to slide in) [newview setframe:cgrectmake(newview.frame.origin.x + newview.frame.size.width, newview.frame.origin.y, newview.frame.size.width, newview.frame.size.height)]; nslog(@"oldview bounds before transition: %f - %f - %f - %f", oldview.frame.origin.x, oldview.frame.origin.y, oldview.frame.size.width, oldview.frame.size.height);  [uiview animatewithduration:1.0 animations:^{     //put in correct position (slide in right left)     [newview setframe:cgrectmake(0, 0, self.headerview.frame.size.width, self.headerview.frame.size.height)];      //slide old view out of view left     [oldview setframe:cgrectmake(-self.headerview.bounds.size.width, 0, self.headerview.frame.size.width, self.headerview.frame.size.height)];     nslog(@"oldview bounds after transition: %f - %f - %f - %f", oldview.frame.origin.x, oldview.frame.origin.y, oldview.frame.size.width, oldview.frame.size.height); } completion:^(bool fin){     //remove old view headerview     [oldview removefromsuperview]; }]; 

log output:

oldview bounds before transition: 0.000000 - 0.000000 - 760.000000 - 400.000000 oldview bounds after transition: -760.000000 - 0.000000 - 760.000000 - 400.000000 

[solution] oldview contained constraints kept view in position, setting:

oldview.translatesautoresizingmaskintoconstraints = yes; 

before animation solved problem.


Comments

Popular posts from this blog

asynchronous - C# WinSCP .NET assembly: How to upload multiple files asynchronously -

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -