翻转动画忽略持续时间,即我无法控制速度

发布于 2024-11-09 15:09:56 字数 1597 浏览 0 评论 0原文

所以我尝试在两个图像之间翻转,但持续时间似乎被忽略了。 我知道苹果必须非常快地制作一些动画才能保持魔力,但是有没有办法减慢翻转速度?

我当前的对象层次结构是游戏板包含许多继承自 UIView 的卡片。 卡片的正面和背面是承载 UIImage 和其他数据的 UIView,

[UIView animateWithDuration:15.0 
    animations:^(void) {
        cardOne.center =CGPointMake(100, 100);
        cardTwo.center =CGPointMake(100, 100);

        //low level calls, to directly perform the image swap 
        [cardOne.face removeFromSuperview]; 
        [cardOne addSubview:cardOne.back];
        [cardOne sendSubviewToBack:cardOne.face]; 

        //calling the transitionFromView to do the image swap
        [UIView transitionFromView:cardOne.face 
                            toView:cardOne.back 
                          duration:10 
                           options:UIViewAnimationTransitionFlipFromLeft 
                        completion:^(BOOL finished){ }];

感谢您的反馈。我尝试将您输入的所有内容混合起来,结果确实正常工作。我还不知道为什么。 感谢您的回复。我尝试恢复到旧的风格并且它起作用了。我还没弄清楚为什么。

非工作代码被注释掉,工作代码不被注释。 再次感谢

/*  
[UIView animateWithDuration:animationDuration  
animations:^{  
    [self.face removeFromSuperview];    
    [self addSubview:self.back];  
    [self sendSubviewToBack:self.face];              
}];  
*/

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:kDefaultFlipSpeed];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
                               forView:self
                                 cache:YES];

[self.face removeFromSuperview];
[self addSubview:self.back];
[self sendSubviewToBack: self.face];

[UIView commitAnimations];

So I attempt to flip between two images, but the duration is seemingly ignored.
I understand that Apple has to do some animation very quickly to keep the magic alive, but is there a way to slow down the flipping?

My current object hierarchy is game board contains many cards which inherit from UIView.
A card has a face and back that are UIViews that host a UIImage and other data

[UIView animateWithDuration:15.0 
    animations:^(void) {
        cardOne.center =CGPointMake(100, 100);
        cardTwo.center =CGPointMake(100, 100);

        //low level calls, to directly perform the image swap 
        [cardOne.face removeFromSuperview]; 
        [cardOne addSubview:cardOne.back];
        [cardOne sendSubviewToBack:cardOne.face]; 

        //calling the transitionFromView to do the image swap
        [UIView transitionFromView:cardOne.face 
                            toView:cardOne.back 
                          duration:10 
                           options:UIViewAnimationTransitionFlipFromLeft 
                        completion:^(BOOL finished){ }];

Thanks for your feedback. I attempted a mix of all you input and it did end up working correctly. I don't yet know why though.
Thanks for your responses. I tried reverting to the old style and it worked. I have not figured out why as yet.

The non-working code is commented out and the working code is left uncommented.
Thanks again

/*  
[UIView animateWithDuration:animationDuration  
animations:^{  
    [self.face removeFromSuperview];    
    [self addSubview:self.back];  
    [self sendSubviewToBack:self.face];              
}];  
*/

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:kDefaultFlipSpeed];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft
                               forView:self
                                 cache:YES];

[self.face removeFromSuperview];
[self addSubview:self.back];
[self sendSubviewToBack: self.face];

[UIView commitAnimations];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼波传意 2024-11-16 15:09:56

我不能在评论中提问,所以:
你尝试过少于10秒的时间吗?更准确地说,在 0-1 秒之间。大约0.5秒。如果您发现这些值的持续时间有任何变化,请告诉我。

我的快速回答是:
尝试将 10 秒设置为 10.010.0f

希望有帮助。

I cant ask in a comment, so:
Have you tried with less than 10 seconds? More precisely between 0-1 second. Something like 0.5 seconds. Tell me if you notice any change in duration with these values.

My quick answer would be:
Try setting 10 seconds as 10.0 or 10.0f.

Hope it helps.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文