2

我想在它所在的地方重新调整按钮的大小并延迟它,你能帮我吗?(发件人=UIButton)

我的功能:

-(IBAction)Animate: (id) sender
{

[sender setBackgroundImage:[UIImage imageNamed:@"Text Bg large.png"] forState:UIControlStateNormal];
CABasicAnimation *scale;
scale = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scale.fromValue = [NSNumber numberWithFloat:1];
scale.toValue = [NSNumber numberWithFloat:1.3];
scale.duration = 1;
scale.removedOnCompletion = NO;

scale.repeatCount = 1;
[sender addAnimation:scale forKey:@""];
[sender setFrame:(CGRectMake(x, y, z, w))];


}

如果我希望该按钮保持在同一位置,并且在不手动输入值的情况下增长 1.3 倍,我对 x、y、z、w 使用什么。哦,我怎么能延迟这个操作?

4

2 回答 2

2

你有什么理由CAAnimation这样做吗?

怎么样:

CGRect newFrame = CGRectInset(sender.frame, CGRectGetWidth(sender.frame) * -0.15, CGRectGetHeight(sender.frame) * -0.15);

[UIView animateWithDuration: 1.0
                      delay: 0.5
                    options: UIViewAnimationOptionCurveLinear
                 animations:^{
                     [sender setFrame: newFrame];
                 }
                 completion: nil];

或者

[UIView animateWithDuration: 1.0
                      delay: 0.5
                    options: UIViewAnimationOptionCurveLinear
                 animations:^{
                     [sender setTransform: CGAffineTransformMakeScale(1.3, 1.3)];
                 }
                 completion: nil];
于 2012-09-05T08:51:38.510 回答
0

做这个:

-(IBAction)Animate:(id) sender
{
  UIButton *btnAnimate = (UIButton *)sender;
  btnAnimate.transform = CGAffineTransformIdentity;
  [UIView animateWithDuration:0.4 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
  btnAnimate.transform = CGAffineTransformMakeScale(1.3f, 1.3f);

  } completion:^(BOOL finished){

    [btnAnimate setFrame:(CGRectMake(x, y, z, w))];

  }];
}
于 2012-09-05T08:50:49.087 回答