Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/114.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 非阻塞UIView动画缩放_Ios_Objective C_Animation_Block_Calayer - Fatal编程技术网

Ios 非阻塞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及其所有内容进行动画缩放。现在我做这个

    [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;
 }];

可能只是手动更改视图框架的大小和原点,而不是使用变换,这是一项更方便的工作,但它应该可以工作