gpt4 book ai didi

ios - CoreAnimation 跟踪原始值

转载 作者:行者123 更新时间:2023-11-29 04:00:28 26 4
gpt4 key购买 nike

我经常面临对 View 进行动画处理并将其恢复到其原始值的要求。 (类似于在 Tap 上放大 UIImageView 并返回)

是否有更优雅的解决方案来跟踪原始值,而不是创建类字段并在 viewDidLoad 上分配这些字段?

你们如何处理这种行为?

最佳答案

如果您对 View 应用变换,则可以在完成后将其设置回恒等变换。此代码创建了一个可放大和缩小的基本切换。

// Check to see if the current transform is identity which means
// no transform applied. If it is, scale the view. Otherwise,
// set it back to identity.
CGFloat scale = 3.0f;
if (CGAffineTransformIsIdentity([_imageView transform])) {
[_imageView setTransform:CGAffineTransformMakeScale(scale, scale)];
} else {
[_imageView setTransform:CGAffineTransformIdentity];
}

这使您不必跟踪起始值。

关于ios - CoreAnimation 跟踪原始值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15923204/

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