在pushViewController过渡期间,UIButton动画可以继续吗?

时间:2015-02-25 05:26:20

标签: ios objective-c

我正在选择按钮增长和缩小而不是突出显示。目标是在点击按钮时使按钮增长...并在发布时同时执行两个动作:

  1. 使用pushViewController进行屏幕转换
  2. 在过渡期间将按钮缩小回正常尺寸
  3. 我的问题:我无法同时完成1& 2。屏幕转换似乎取消了发布动画。在过渡期间,按钮仍保持大尺寸。

    Screeshots

    • 左下角的正常尺寸Feed按钮enter image description here
    • 按比例放大Feed按钮,在屏幕转换过程中卡住该按钮enter image description here

    buttonPress和buttonRelease的动画方法:

    - (void)buttonPress:(UIButton*)button{
        POPSpringAnimation *scaleAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY];
        scaleAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(1.5, 1.5)];
        scaleAnimation.springBounciness = 15.f;
        [button.layer pop_addAnimation:scaleAnimation forKey:@"scaleAnim"];
        button.highlighted = NO;
    }
    
    
    - (void)buttonRelease:(UIButton*)button {
        POPSpringAnimation *scaleAnimation = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerScaleXY];
        scaleAnimation.toValue = [NSValue valueWithCGSize:CGSizeMake(1.0, 1.0)];
        scaleAnimation.springBounciness = 15.f;
        [button.layer pop_addAnimation:scaleAnimation forKey:@"scaleAnim"];
        button.highlighted = NO;
    }
    

    将动画附加到按钮的方法:

    - (void)attachAnimationsToButton:(UIButton *)button
    {
        [button addTarget:self action:@selector(buttonPress:) forControlEvents:UIControlEventTouchDown];
        [button addTarget:self action:@selector(buttonPress:) forControlEvents:UIControlEventTouchDragInside];
        [button addTarget:self action:@selector(buttonRelease:) forControlEvents:UIControlEventTouchUpInside];
        [button addTarget:self action:@selector(buttonRelease:) forControlEvents:UIControlEventTouchDragExit];
        [button addTarget:self action:@selector(buttonRelease:) forControlEvents:UIControlEventTouchUpOutside];
    }
    

    Feed按钮:

     self.feedButton = [[UIButton alloc] init];
     [self.feedButton setImage:[UIImage tag_feedButtonImage] forState:UIControlStateNormal];
     [self attachAnimationsToButton:self.feedButton];
     [self.feedButton addTarget:self action:@selector(showFeed) forControlEvents:UIControlEventTouchUpInside];
     [self addSubview:self.feedButton];
    

    显示Feed方法:

    - (void)showFeed
    {   
        [self.navigationController pushViewController:[TAGTabBarController new] animated:NO];
    }
    

    提前感谢您的帮助!

    -Josh

0 个答案:

没有答案