gpt4 book ai didi

ios - 非阻塞 UIView 动画缩放

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:30:21 27 4
gpt4 key购买 nike

我想以非阻塞方式动画缩放 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com