使用 NSNumber 初始化 CATransition 持续时间

Initialise CATransition duration with NSNumber

我想用 NSNumber 初始化 CATransition 的持续时间,我该怎么做,因为 animation.duration 是一个 NSTimeInterval 对象?

- (void)startPopUpAnimation:(NSNumber *)numbers {

    CATransition *animation = [CATransition animation];
    animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    animation.type = kCATransitionFade;
    animation.duration = @"2.15";//[NSNumber numberWithDouble:[numbers doubleValue]];

}

这比我想象的要容易:

animation.durationtypedef double 所以我刚刚做了:animation.duration = [numbers doubleValue];