IOS

CGAffineTransformMakeScale(0, 0)

2015-10-25  本文已影响2606人  Andy矢倉

最近的任务大多数是做UI和动画,今天遇到一个低级错误。

执行一个消失动画,把transform scale设置成0.0和0.0,打死动画都出不来,一直闪现

__weak __typeof__(self)weakSelf = self;
[UIView animateWithDuration:0.3f animations:^{
    __strong __typeof__(self)strongSelf = weakSelf;
    strongSelf.containerView.transform = CGAffineTransformMakeScale(0.0f, 0.0f);
    strongSelf.containerView.alpha = 0.0f;
} completion:^(BOOL finished) {
    [UIView animateWithDuration:0.3f animations:^{
        __strong __typeof__(self)strongSelf = weakSelf;
        strongSelf.alpha = 0.0f;
    } completion:^(BOOL finished) {
        if (completed) {
            completed();
        }
        __strong __typeof__(self)strongSelf = weakSelf;
        [strongSelf removeFromSuperview];
    }];
}];

查了老半天资料得知,CGAffineTransformMakeScalexy参数为零不会触发动画,直接就消失处理,把两个参数改大就好了

strongSelf.containerView.transform = CGAffineTransformMakeScale(0.01f, 0.01f);
strongSelf.containerView.alpha = 0.0f;
上一篇 下一篇

猜你喜欢

热点阅读