gpt4 book ai didi

iphone - 闪烁/闪烁UIView

转载 作者:行者123 更新时间:2023-11-28 22:51:18 25 4
gpt4 key购买 nike

我需要在按下按钮或完成任务时为 UIView 提供一些拉伸(stretch)和倾斜动画。

应用于 UIView 的大多数动画通常在将它们添加到 UIView 或从中删除时应用,但是我如何使用已添加到 View 的 View 来实现这一点.

动画可以是任何东西,只要它能引起用户的注意(表明任务已完成)。

最佳答案

编辑 How to scale and rotate a view in a single animation

您可能需要使用 Core Animation 并将两个动画添加到一个组中:

CABasicAnimation *stetchAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale.x"];
stetchAnimation.toValue = [NSNumber numberWithDouble:(someView.frame.size.width+100)/someView.frame.size.width];

CABasicAnimation *skewAnimation = CABasicAnimation animationWithKeyPath:@"transform.rotation.x"];
stetchAnimation.toValue:[NSNumber numberWithInt:180];

//Add both animation at time when task is completed

CAAnimationGroup *animationGroup = [CAAnimationGroup animation];
animationGroup.animations = [NSArray arrayWithObjects:stetchAnimation,skewAnimation,nil];
animationGroup.removedOnCompletion = YES;
animationGroup.fillMode = kCAFillModeForwards;
animationGroup.duration = 0.7; // increase duration if needed

[someView.layer addAnimation:animationGroup forKey:@"animations"];

关于iphone - 闪烁/闪烁UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11928506/

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