使用CATransition做动画时遇到的问题

    CATransition *animation = [CATransition animation];
    [animation setDelegate:self];
    [animation setDuration:1.0f];
    [animation setTimingFunction:UIViewAnimationCurveEaseInOut];
    [animation setType: kCATransitionPush];
    [animation setSubtype: kCATransitionFromLeft];
    
    [[self superview] exchangeSubviewAtIndex:0 withSubviewAtIndex:1];

    [[[self superview] layer] addAnimation:animation forKey:@"transitionViewAnimation"];  


如下这行代码是错误的

[animation setTimingFunction:UIViewAnimationCurveEaseInOut];

UIViewAnimationCurveEaseInOut为0,在这里其实就是空指针。

[animation setTimingFunction:UIViewAnimationCurveEaseInOut];其实就是[animation setTimingFunction:nil];

正确的写法应该是

animation.timingFunction =  [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];

你可能感兴趣的:(使用CATransition做动画时遇到的问题)