我正在选择按钮增长和缩小而不是突出显示。目标是在点击按钮时使按钮增长...并在发布时同时执行两个动作:
我的问题:我无法同时完成1& 2。屏幕转换似乎取消了发布动画。在过渡期间,按钮仍保持大尺寸。
Screeshots
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