开发者

Flip animation is ignoring duration, i.e. I can't control speed

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];


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜