最近的任务大多数是做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];
}];
}];
查了老半天资料得知,CGAffineTransformMakeScale
里x
和y
参数为零不会触发动画,直接就消失处理,把两个参数改大就好了
strongSelf.containerView.transform = CGAffineTransformMakeScale(0.01f, 0.01f);
strongSelf.containerView.alpha = 0.0f;