我想以非阻塞方式对 UIView 及其所有内容进行动画缩放。目前我正在这样做...
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.1];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
CGAffineTransform transform = CGAffineTransformMakeScale(1.1,1.1);
self.view.transform = transform;
[UIView commitAnimations];
但是它阻塞。我宁愿使用类似...
[UIView animateWithDuration:0.2
animations:^{
CGAffineTransform transform = CGAffineTransformMakeScale(1.1,1.1);
self.view.transform = transform;
}];
...但 animateWithDuration 不适用于 CALayer/CGAffineTransform 转换。如何在不阻塞任何内容的情况下实现相同的动画?
最佳答案
尝试使用:
[UIView animateWithDuration:0.2
animations:^{
CGAffineTransform transform =
CGAffineTransformScale(CGAffineTransformIdentity, 2.0, 2.0);
self.view.transform = transform;
}];
只需为这个出色的答案添加一个有用的注释,几乎总是您想要打开光栅化,因此它看起来很流畅
self.view.layer.shouldRasterize = YES;
[UIView animateWithDuration:0.2
animations:^{
CGAffineTransform transform =
CGAffineTransformScale(CGAffineTransformIdentity, 0.5, 0.5);
self.view.transform = transform;
}];
关于ios - 非阻塞 UIView 动画缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16546950/