Ber*_*rnd 2 animation block objective-c calayer ios
我想以非阻塞方式动画缩放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];
Run Code Online (Sandbox Code Playgroud)
然而它是封锁的.我宁愿使用像...这样的东西
[UIView animateWithDuration:0.2
animations:^{
CGAffineTransform transform = CGAffineTransformMakeScale(1.1,1.1);
self.view.transform = transform;
}];
Run Code Online (Sandbox Code Playgroud)
...但是animateWithDuration不适用于CALayer/CGAffineTransform转换.如何在不阻挡任何内容的情况下实现相同的动画?
尝试使用:
[UIView animateWithDuration:0.2
animations:^{
CGAffineTransform transform =
CGAffineTransformScale(CGAffineTransformIdentity, 2.0, 2.0);
self.view.transform = transform;
}];
Run Code Online (Sandbox Code Playgroud)
只需在这个伟大的答案中添加一个有用的注释,几乎总是你想打开光栅化,所以它看起来很流畅
self.view.layer.shouldRasterize = YES;
[UIView animateWithDuration:0.2
animations:^{
CGAffineTransform transform =
CGAffineTransformScale(CGAffineTransformIdentity, 0.5, 0.5);
self.view.transform = transform;
}];
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2350 次 |
| 最近记录: |