0

アプリを開いUIButtonUIViewControllerときに表示する「フェードイン」が現在あります。 代わりに、左から右にスライドさせたいと思います。UIButton

「フェードイン」をしっかりと行ったにもかかわらず、左から右にスライドさせる方法がわかりません。私の試みは失敗しました。

何か助けてくれませんか?ありがとう!必要に応じてコードを追加できます-

ViewController.h

@property (weak, nonatomic) IBOutlet UIButton *buttonOne;

ViewController.m

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the 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];
}
4

2 に答える 2

1
//Set your button off the screen to the left
yourButton.frame = CGRectMake(-yourButton.frame.size.width, yourButton.frame.origin.y, CGRectGetWidth(yourButton.frame), CGRectGetHeight(yourButton.frame));

//Create the ending frame or where you want it to end up on screen
CGRect newFrm = yourButton.frame;
newFrm.origin.x = 100;

//Animate it in
[UIView animateWithDuration:2.0f animations:^{
    yourButton.frame = newFrm;
}];
于 2013-07-24T00:46:27.853 に答える