Ios 非阻塞UIView动画缩放
我想以非阻塞的方式对UIView及其所有内容进行动画缩放。现在我做这个Ios 非阻塞UIView动画缩放,ios,objective-c,animation,block,calayer,Ios,Objective C,Animation,Block,Calayer,我想以非阻塞的方式对UIView及其所有内容进行动画缩放。现在我做这个 [UIView beginAnimations:nil context:NULL]; [UIView setAnimationDuration:0.1]; [UIView setAnimationDelegate:self]; [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; CGAffineTransf
[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;
}];
可能只是手动更改视图框架的大小和原点,而不是使用变换,这是一项更方便的工作,但它应该可以工作