objective c - IOS stop UIbutton to take its own place after animation completed -
i have set animation seen in below image. in uibutton move left right , top bottom. animation work correctly after completion of animation uibutton comes original place before segue perform. so, it's not good. want set after completion of animation uibutton can't come it's own place before segue .
here try image.
//move button left right - (ibaction)btneasy:(id)sender { easy=yes; nslog(@"your x is: %f ", self.btneasy.frame.origin.x); nslog(@"your y is: %f ", self.btneasy.frame.origin.y); x1=self.btneasy.frame.origin.x; y1=self.btneasy.frame.origin.y; cgrect screenrect = [[uiscreen mainscreen] bounds]; [uiview animatewithduration:1.150 delay:0 options:uiviewanimationoptioncurveeaseinout animations:^{ self.btneasy.frame = cgrectmake(screenrect.size.width/1.80, self.btneasy.frame.origin.y, self.btneasy.frame.size.width, self.btneasy.frame.size.height); [self performselector:@selector(btneasyanimation) withobject:self afterdelay:1.160 ];} completion:^(bool finished) { }]; //move button top bottom if (easy==yes) { if (isipad2 || isipadair || isipadratina) { //[self.view layoutifneeded]; [uiview beginanimations:nil context:null]; [uiview setanimationbeginsfromcurrentstate:yes]; [uiview setanimationduration:1.0]; [_btneasy setframe:cgrectmake(self.view.frame.origin.x+290, self.view.frame.origin.y+900, self.btneasy.frame.size.width, self.btneasy.frame.size.height)]; [uiview commitanimations]; } else if (isiphone4s) { [uiview beginanimations:nil context:null]; [uiview setanimationbeginsfromcurrentstate:yes]; [uiview setanimationduration:1.0]; [_btneasy setframe:cgrectmake(self.view.frame.origin.x+92, self.view.frame.origin.y+428, self.btneasy.frame.size.width, self.btneasy.frame.size.height)]; [uiview commitanimations]; } } [self performselector:@selector(segueemethod) withobject:self afterdelay:1.160 ];
image :-
if not placing directly button given frame, using autolayout (autoresize end same effect). need explicitly use autolayout, retain reference constraints , update them (you can search here how that) , set uiview
animation block [button layoutifneeded]
you can see detailed answer in this answer
Comments
Post a Comment