【问题标题】:iPhone slide animation when view is loaded加载视图时的 iPhone 幻灯片动画
【发布时间】:2012-08-08 05:34:57
【问题描述】:

如何在 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
    }];
}

【问题讨论】:

    标签: iphone ipad uiview uiviewanimation


    【解决方案1】:

    为什么不呢?

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

    【讨论】:

    • 在第一帧中给出要在屏幕上显示的帧的确切位置或其他任何东西
    • 第一帧表示动画的视图开始位置,如你所愿,它应该位于屏幕的左侧,在里面或外面
    • 好的,谢谢我得到了这个工作但是你能告诉我这个视图什么时候加载然后点击另一个按钮我希望这个视图应该被隐藏并且在按钮点击时重新加载
    • 我不太明白..应该再动画吗?
    • 再次感谢在玩代码后得到了解决方案,非常感谢
    猜你喜欢
    • 2011-12-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-12
    • 2015-08-08
    • 1970-01-01
    • 1970-01-01
    • 2019-11-16
    相关资源
    最近更新 更多