加载视图时的iPhone幻灯片动画

时间:2012-08-08 05:34:57

标签: iphone ipad uiview uiviewanimation

如何在iPhone应用程序中加载视图时执行滑动动画?

我有一个ViewController,我有子视图。我希望子视图加载动画,从左向右滑动。

到目前为止,我得到了这段代码:

-(void) showAnimation{

    [self.view addSubview:geopointView]
    geopointView.frame = CGRectMake(20,150,550,200)// somewhere offscreen, in the direction you want it to appear from
    [UIView animateWithDuration:10.0 
         animations:^{
             geopointView.frame = CGRectMake(20,150,550,200)// its final location
    }];
}

1 个答案:

答案 0 :(得分:0)

为什么不呢?

-(void) showAnimation{
[self.view addSubview:geopointView]
geopointView.frame = CGRectMake(-200,150,550,200)// just set a different frame
[UIView animateWithDuration:10.0 
             delay:0.0
             options:UIViewAnimationCurveEaseOut
             animations:^{
                 geopointView.frame = CGRectMake(20,150,550,200)// its final location
             }
             completion:nil];
}