【问题标题】:How to hide view when animation ends?动画结束时如何隐藏视图?
【发布时间】:2011-09-06 01:28:20
【问题描述】:

我正在使用效果很好的 curlup 和 curldown 动画。我的问题是我的视图在它推动视图控制器之前仍然存在一秒钟。动画结束时如何隐藏当前视图?

【问题讨论】:

    标签: ios4 iphone-sdk-3.0 core-animation cocos2d-iphone


    【解决方案1】:

    希望这段代码对你有所帮助....

    检查一遍.....

    当您的动画完成时,“customView”帧大小设置为 (x,y,0,0).... 如下所示

    -(void)close_but{   
    CGRect viewTopFrame = CGRectMake(150,240,0,0);
    [UIView animateWithDuration:0.5
                delay:0
                options: UIViewAnimationCurveEaseOut
                 animations:^{
                     "customView".frame = viewTopFrame;
    
                         } 
                         completion:^(BOOL finished){
                             NSLog(@"Done!");
                         }];
    customView.frame=viewTopFrame;
    

    【讨论】:

      【解决方案2】:

      一旦动画完成,您可以将视图的 alpha 设置为 0,例如:

      [customView setAlpha:0];
      

      【讨论】:

      • 当我向前翻转时效果很好,但是当我尝试返回时它给了我一个空白视图。我正在使用 popviewcontroller 来翻转... [[self navigationController] popViewControllerAnimated:NO];
      • 您必须在 viewWillAppear 中通过将其 alpha 设置为 1 来再次处理它
      • 有效!当我翻转回原始视图时,我将获得最后一个视图几秒钟。
      • 我有 [self.view alpha:1];在 viewWillAppear 中……就是这样。跟我的观点有关系吗?
      猜你喜欢
      • 2020-06-23
      • 1970-01-01
      • 1970-01-01
      • 2018-03-01
      • 1970-01-01
      • 2014-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多