1

我在重复/反转动画中使用仿射变换来创建“脉冲”效果。但是,我注意到按钮在动画开始时向右移动。按钮的锚点位于 (0.5,0.5):

   [UIView animateWithDuration:0.5
                          delay:0
                        options:UIViewAnimationOptionRepeat|
     UIViewAnimationOptionAutoreverse|
     UIViewAnimationOptionAllowUserInteraction|
     UIViewAnimationCurveEaseInOut
                     animations:^{
                         self.recordButton.transform = CGAffineTransformMakeScale(1.2, 1.2);
                     } completion:^(BOOL finished) {

                     }];

看起来,当应用变换时,按钮框架的原点保持在同一位置。

如何为缩放变换设置动画,以便在应用变换后按钮的中心保持在同一位置?

4

1 回答 1

0

我通常使用 frame 和 CGRect 实用函数

[UIView animateWithDuration:0.5
                      delay:0
                    options:UIViewAnimationOptionRepeat|
 UIViewAnimationOptionAutoreverse|
 UIViewAnimationOptionAllowUserInteraction|
 UIViewAnimationCurveEaseInOut
                 animations:^{
                     self.recordButton.frame = CGRectInset(self.recordButton.frame, -1.2, -1.2);
                 } completion:^(BOOL finished) {

                 }];
于 2014-07-24T19:22:45.133 回答