2011-11-22 109 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]; 
}