我是核心情节的新手。最近我决定在我的情节中添加条形增长动画。所以我按照这里搜索的指令来实现动画。现在我想出了问题:动画似乎没有生效。委托:didStopAnimate:(BOOL) 无论我将动画的持续时间设置为 false 多长时间都会返回。还要说明一件事:在图形视图中,我在真实图形托管视图下放置了一个滚动视图。这会影响核心动画的工作吗?该图出现在从表格视图导航到自身之后。这是我的一些代码:
if ([plot_type isEqualToString:@"bar"]) {
CPTBarPlot *plot = [[CPTBarPlot alloc] init];
//id
plot.identifier = [d objectForKey:@"title"];
plot.title = [d objectForKey:@"title"];
plot.lineStyle = barLineStyle;
plot.barCornerRadius = 1.2;
//set color
CPTGradient *gradient = [CPTGradient gradientWithBeginningColor:[CPTColor colorWithCGColor:color_begin] endingColor:[CPTColor colorWithCGColor:color_end]];
gradient.angle = 90.0f;
CPTFill *fill = [CPTFill fillWithGradient:gradient];
plot.fill = fill;
//bar width
double width = [[d objectForKey:@"width"] doubleValue]==0.0?0.6:[[d objectForKey:@"width"] doubleValue];
plot.barWidth = CPTDecimalFromFloat(width);
plot.barsAreHorizontal = NO;
//need manually stacked
if (need_stack && !is_first) {
plot.barBasesVary = YES;
} else {
plot.barBasesVary = NO;
}
//data source
plot.dataSource = self;
//delegate
plot.delegate = self;
CABasicAnimation *anim = [CABasicAnimation animationWithKeyPath:@"transform"];
[anim setDuration:2.0f];
anim.toValue = [NSNumber numberWithFloat:1];
anim.fromValue = [NSNumber numberWithFloat:0.0f];
anim.removedOnCompletion = NO;
anim.delegate = self;
anim.fillMode = kCAFillModeForwards;
[plot addAnimation:anim forKey:(NSString *)plot.identifier];
[graph addPlot:plot toPlotSpace:plotSpace];
}
提前感谢您的帮助。