ios - 非阻塞 UIView 动画缩放

标签 ios objective-c animation block calayer

我想以非阻塞方式对 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/

相关文章:

ios - 创建按钮网格时点击并长按手势Objective-C

ios - 在 iOS 中使用 CFB8 和无填充的 3DES 加密?

ios - RestKit:忽略一些动态嵌套属性

objective-c - 是否可以从 Mac 系统设置中获取代理设置用户名和密码?

objective-c - Xcode 无法识别通过类别添加的方法

android - 如何对角地翻译图像上的动画?

c++ - 如何使用Assimp获取模型动画?

ios - 在 UITableViewCell 中有条件地移动和删除布局对象

ios - 在 UITableView 的自定义 Prototype Cell 中,UITextField 值替换为其他 Prototype Cell

jQuery 平滑内容滑动