简体   繁体   English

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

[英]iPhone slide animation when view is loaded

How to perform a sliding animation when a view is being loaded in an iPhone application? 在iPhone应用程序中加载视图时如何执行滑动动画?

I have a ViewController in which I have subview. 我有一个ViewController,其中有子视图。 I want that the subview be loaded with an animation, sliding from the left to the right. 我希望子视图加载有动画,从左到右滑动。

I got this code so far: 到目前为止,我已经获得了以下代码:

-(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
    }];
}

why not? 为什么不?

-(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];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM