2011-11-22 76 views
0

请指导我如何通过单手指触摸(时钟和反时钟方向)旋转CPTGraphHostingView如何在核心情节旋转CPTGraphhostingview

感谢

+0

可能重复[旋转饼图这与触摸事件的CALayer(http://stackoverflow.com/questions/6788375/rotate-pie-chart-which-是-A-的CALayer与 - 触摸事件) –

回答

1

//我已经使用这个代码旋转的饼图几秒钟没有用户交互。

-(void)ConstPieChart 
{ 
    graph = [[CPXYGraph alloc] initWithFrame: CGRectZero]; 

    viewGraphHostingPie.hostedGraph=graph; 

    CPPieChart *pieChart = [[CPPieChart alloc] init]; 
    pieChart.dataSource = self; 
    pieChart.delegate = self; 
    pieChart.pieRadius = 100.0; 
    pieChart.identifier = @"PieChart1"; 
    pieChart.startAngle=0; 
    //pieChart.startAngle = M_PI_4; 
    pieChart.sliceDirection = CPPieDirectionCounterClockwise; 



    NSMutableArray *ValueArray = [[NSMutableArray alloc]init]; 
    ValueArray = [NSArray arrayWithObjects:[NSNumber numberWithDouble:57.03],[NSNumber numberWithDouble:66.00],[NSNumber numberWithDouble:77.03],nil]; 
    self.pieData = ValueArray; 




    CABasicAnimation *rotation = [CABasicAnimation animationWithKeyPath:@"transform"]; 
    CATransform3D transform = CATransform3DMakeRotation(360, 0, 0, 1); 
    rotation.toValue = [NSValue valueWithCATransform3D:transform]; 
    rotation.duration = 15.0f; 
    [pieChart addAnimation:rotation forKey:@"rotation"]; 
    [graph addPlot:pieChart]; 
    [pieChart release]; 
}