Ios 如何格式化y轴的文本

Ios 如何格式化y轴的文本,ios,core-plot,Ios,Core Plot,y轴的文本显示为小数点,但我需要将其显示为整数值。例如,3000.0应显示为3000 但yAxis间隔长度在源中声明为 @property (nonatomic, readwrite, assign) NSDecimal majorIntervalLength; 我怎样才能做到这一点 y轴刻度由以下公式计算: NSString *yMajorIntervalLength = [[NSNumber numberWithFloat:(yMaxRange / 10)] stringValue];

y轴的文本显示为小数点,但我需要将其显示为整数值。例如,3000.0应显示为3000

但yAxis间隔长度在源中声明为

@property (nonatomic, readwrite, assign) NSDecimal majorIntervalLength;
我怎样才能做到这一点

y轴刻度由以下公式计算:

NSString *yMajorIntervalLength = [[NSNumber numberWithFloat:(yMaxRange / 10)] stringValue];
CPTXYAxis *y = axisSet.yAxis;
y.axisLineStyle               = nil;
y.majorTickLineStyle          = nil;
y.minorTickLineStyle          = nil;
y.majorIntervalLength         = CPTDecimalFromString(yMajorIntervalLength);

Try-setMaximumFractionDigits:和-setMinimumFractionDigits:


这些配置了十进制分隔符后的位数。

您可以尝试类似的方法

[yMajorIntervalLength stringByDeletingPathExtension]
:)

NSRange dotRange = [yMajorIntervalLength rangeOfString:@"." options:NSBackwardsSearch];
if (dotRange.location != NSNotFound)
    test = [yMajorIntervalLength substringToIndex:dotRange.location];