ios - UIButton slide in, instead of fade in -


i have uibutton in uiviewcontroller have "fading in" view when app opened. i uibutton slide in left right instead though.

i can't figure out how slide in left right , attempts have failed, though i've got "fade in" thing down solid.

any give me? thanks! can add more code needed-

viewcontroller.h

@property (weak, nonatomic) iboutlet uibutton *buttonone; 

viewcontroller.m

- (void)viewdidload {     [super viewdidload];     // additional setup after loading view.         nstimer *timermovebutton = [nstimer scheduledtimerwithtimeinterval:1.0 target:self selector:@selector(movebutton) userinfo:nil repeats:no];     [timermovebutton fire]; }  -(void) movebuttontwo {     buttontwo.alpha = 0;     [uiview beginanimations:nil context:nil];     [uiview setanimationdelay:0.5];     [uiview setanimationcurve:uiviewanimationtransitioncurlup];      [uiview setanimationdelegate:self];     [uiview setanimationduration:1.0];     buttontwo.alpha = 1.0;      [uiview setanimationdidstopselector:@selector(animationdidstop:finished:context:)];     [uiview commitanimations]; } 

you need animate buttons frame, not use animation curve.

since ios 4, we've had uiview animation blocks:

// first set uibutton frame outside of view: // concerned it's location on x-axis let's keep properties same [buttontwo setframe:cgrectmake(cgrectgetmaxx(self.view.frame), cgrectgetminy(buttontwo.frame), cgrectgetwidth(buttontwo.frame), cgrectgetheight(buttontwo.frame))]; [uiview animatewithduration:0.5                       delay:0                     options:uiviewanimationcurveeaseout                  animations:^{                      // set new frame                      [buttontwo setframe:cgrectmake(0, cgrectgetminy(buttontwo.frame), cgrectgetwidth(buttontwo.frame), cgrectgetheight(buttontwo.frame))];                  }                   completion:^(bool finished){                      nslog(@"done!");                  } ]; 

there's good tutorial on @ ray wenderlich can check out learn more.


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -