gpt4 book ai didi

ios - UIView animateKeyFramesWithDuration 没有在正确的时间开始

转载 作者:行者123 更新时间:2023-11-28 21:33:43 25 4
gpt4 key购买 nike

我很困惑为什么这不起作用。我这三个事件接连发生。第一个缩小和缩小图像,第二个在背景中淡入淡出,第三个为第一张图像设置动画。但它实际上是反过来发生的吗?我做了什么傻事吗?

    [UIView animateKeyframesWithDuration:2.0 delay:0.0 options:UIViewKeyframeAnimationOptionBeginFromCurrentState animations:^{
[UIView addKeyframeWithRelativeStartTime:0.0 relativeDuration:0.25 animations:^{
[v setFrame:CGRectMake(self.view.center.x - 125, self.view.center.y - 125, 250, 250)];
}];
[UIView addKeyframeWithRelativeStartTime:0.50 relativeDuration:0.75 animations:^{
[UIView transitionWithView:self.fullView
duration:0
options:UIViewAnimationOptionTransitionCrossDissolve
animations:NULL
completion:NULL];

[self.fullView setHidden:NO];
}];
[UIView addKeyframeWithRelativeStartTime:1.50 relativeDuration:0.5 animations:^{
v.animationImages = [self.imageDict objectForKey:id];
v.animationRepeatCount = 1;
[v startAnimating];
}];
}
completion:nil];

编辑//除了拼写错误(addKeyFrameWithRelativeStartTime 为 1.50)之外,第三个 block 无法正常工作,因为 UIImageView startAnimating 方法需要放在完成 block 中。

最佳答案

您的代码看起来很可疑。您添加的最后一个关键帧动画的相对开始时间为 1.5。那有什么作用?它应该在 0 到 1 的范围内。

来自苹果文档,

帧开始时间

The time at which to start the specified animations. This value must be in the range 0 to 1, where 0 represents the start of the overall animation and 1 represents the end of the overall animation. For example, for an animation that is two seconds in duration, specifying a start time of 0.5 causes the animations to begin executing one second after the start of the overall animation.

帧持续时间

The length of time over which to animate to the specified value. This value must be in the range 0 to 1 and indicates the amount of time relative to the overall animation length. If you specify a value of 0, any properties you set in the animations block update immediately at the specified start time. If you specify a nonzero value, the properties animate over that amount of time. For example, for an animation that is two seconds in duration, specifying a duration of 0.5 results in an animation duration of one second.

我很确定将值固定在范围内会产生一些好的变化。但是,我不确定它是否能解决您的问题,因为我不理解您的动画代码。

关于ios - UIView animateKeyFramesWithDuration 没有在正确的时间开始,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34789607/

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