점을 선택,하지만 난 선택하면 다른 지점에서 다른 설정 색상의 포인트는 어떻게 구현, 구별하는이 시점에서 희망핵심 플롯 덕분에 많이 나는 성공적으로 포인트를 선택한
방법 이 부분 만 빨간색으로 설정하십시오.
- (무효) 산점도 (CPTScatterPlot *) 플롯 plotSymbolWasSelectedAtRecordIndex (NSUInteger) 인덱스 { CPTXYGraph 그래프 = (CPTXYGraph) _graph;
if (_symbolTextAnnotation){
[graph.plotAreaFrame.plotArea removeAnnotation:_symbolTextAnnotation];
_symbolTextAnnotation = nil;
}
// Setup a style for the annotation
CPTMutableTextStyle *hitAnnotationTextStyle = [CPTMutableTextStyle textStyle];
hitAnnotationTextStyle.color = [CPTColor whiteColor];
hitAnnotationTextStyle.fontSize = 16.0;
hitAnnotationTextStyle.fontName = @"Helvetica-Bold";
// Determine point of symbol in plot coordinates
NSDictionary *dataPoint = _plotData[index];
NSNumber *x = dataPoint[@"x"];
NSNumber *y = dataPoint[@"y"];
NSArray *anchorPoint = @[x, y];
float yValue = [y floatValue];
NSString *yString = [NSString stringWithFormat:@"%.1f",yValue];
CPTTextLayer *textLayer = [[CPTTextLayer alloc] initWithText:yString style:hitAnnotationTextStyle];
CPTImage *background = [CPTImage imageWithCGImage:[UIImage imageNamed:@"bg_red"].CGImage];
textLayer.fill = [CPTFill fillWithImage:background];
textLayer.paddingLeft = 2.0;
textLayer.paddingTop = 2.0;
textLayer.paddingRight = 2.0;
textLayer.paddingBottom = 2.0;
self.symbolTextAnnotation = [[CPTPlotSpaceAnnotation alloc] initWithPlotSpace:graph.defaultPlotSpace anchorPlotPoint:anchorPoint];
_symbolTextAnnotation.contentLayer = textLayer;
_symbolTextAnnotation.contentAnchorPoint = CGPointMake(0.5, 0.0);
_symbolTextAnnotation.displacement = CGPointMake(0.0, 10.0);
[graph.plotAreaFrame.plotArea addAnnotation:_symbolTextAnnotation];
}
에릭, 고마워, 이미 팁에 따라 문제를 해결했습니다 – ilyon