UIButton不会执行CATransform3DMakeScale

时间:2014-07-23 12:39:16

标签: ios uibutton

我正在尝试在CATransform3DMakeScale图层上执行UIButton's,但缩放转换似乎不起作用。位置动画有效,但比例不是

[UIView animateWithDuration:animationOutDuration delay:0.0f
                    options:UIViewAnimationOptionCurveEaseIn
                 animations:^{
                     self.alpha = 0.0f;
                     CGPoint position = self.layer.position;
                     position.y += self.bounds.size.height*animationTranslationPercentage;
                     self.layer.position = position;
                     self.layer.transform = CATransform3DMakeScale(animateOutEndScale, animateOutEndScale, 1.0f);

                } completion:^(BOOL finished) {

1 个答案:

答案 0 :(得分:1)

我写了一些像你的代码,替换了一些参数。它工作正常。

UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(120.0f, 20.0f, 100.0f, 50.0f)];
[button setBackgroundColor:[UIColor redColor]];
[button setTitle:@"lololo" forState:UIControlStateNormal];
[self.view addSubview:button];

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(2.0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
    [UIView animateWithDuration:1.0
                          delay:0.0f
                        options:UIViewAnimationOptionCurveEaseIn
                     animations:^{
                         button.alpha = 0.0f;
                         CGPoint position = button.layer.position;
                         position.y += button.bounds.size.height*2.0;
                         button.layer.position = position;
                         button.layer.transform = CATransform3DMakeScale(1.5, 1.5, 1.0f);

                     } completion:^(BOOL finished) {

                     }];
});

按钮向下移动,缩放和淡化。

所以我猜你的animateOutEndScale可能是1.0f

相关问题