2

我想以非阻塞方式动画缩放 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 转换。如何在不阻塞任何东西的情况下实现相同的动画?

4

1 回答 1

5

尝试使用:

[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;
 }];
于 2013-05-14T15:38:49.733 回答