不希望按钮立刻消失,最好是有个过渡慢慢消失,这种效果怎么做呢?
谢谢!

解决方案 »

  1.   

    加个动画就行了。随便写一个:按钮向中间慢慢消失:[UIView beginAnimations:@"ani" context:NULL];
        [UIView setAnimationDuration:1.0];
        btn.frame = CGRectMake(btn.center.x, btn.center.y, 0, 0);
        [UIView commitAnimations];
      

  2.   


    我怎么看不出是btn触发了动画呢???
    似乎这段代码和btn无关啊
      

  3.   


    你把这段代码加到btn的点击事件里不就是btn触发的了么?
      

  4.   

    我是用定时器让按钮3秒后自动消失,不是点击按钮让按钮消失啊,这种情况也可以添加上动画吗?
    -(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
        NSLog(@"touchesEnded");
        buttom.hidden=NO;    if (timer != nil) {
                NSLog(@"is valid");
                [timer invalidate];
                timer = nil ;
        }    timer = [NSTimer scheduledTimerWithTimeInterval: 3.0f
                                                 target: self
                                               selector: @selector(handleTimer:)//设定定时器回
                                               userInfo: nil
                                                repeats: NO];
    }- (void) handleTimer: (NSTimer *) timer1
    {
        //在这里进行处理
        [buttom setHidden:YES];
        if (timer != nil) {
            [timer invalidate];
            timer = nil ;
        }
    }
      

  5.   

    你这只是一个动画,没必要用到定时器。用之前@ccf0703的方法即可
      

  6.   

    如果是指可见度渐变为0之后还需要移除按钮,那么可以在声明动画的时候给动画设置一个完成的代理方法,在代理方法里面将这个按钮移除即可。或者使用block的方法如下:    [UIView animateWithDuration:3. animations:^{
            btn.alpha = 0;
        } completion:^(BOOL finished) {
            [btn removeFromSuperview];
        }];
    这样即可
      

  7.   

    在车上。
    你这样做
    1 在屏幕上放一个View作为所有要隐藏元素的superview,设置其alpha为0
    2 给这个view加一个UITapGestureReconizer手势
    3 在手势回调方法中判断view的alpha值,然后使用上述的block来显示或英藏这个view