[英]how to show $ sign in the y-axis on the graph value in iphone app
我有显示给定值的百分号的图形,但我想在代码中将$更改为$,但它也隐藏了所有值
-(void)drawHistogramWithItem:(ECGraphItem *)item index:(int)index color:(UIColor *)color
{
if (index != 0)
_histogramStartX += _histogramSpacing + item.width;
CGRect rect = CGRectMake(_histogramStartX, _xaxisStart.y - _ySpacingScale*item.yValue,item.width, _ySpacingScale*item.yValue);
[color setFill];
[[UIColor blackColor] setStroke];
CGContextAddRect(_context,rect);
CGContextDrawPath(_context, kCGPathFillStroke);
[[UIColor blackColor] set];
NSString *percentage = [NSString stringWithFormat:@"%.1f%%",item.yValue];
[percentage drawAtPoint:CGPointMake(_histogramStartX,_xaxisStart.y - _ySpacingScale*item.yValue - 15) withFont:[UIFont boldSystemFontOfSize:10]];
[self drawWords:item.name AtPoint:CGPointMake(_histogramStartX + item.width/8 ,_xaxisStart.y + 5) color:[UIColor blackColor]];
}
只需更改:
NSString *percentage = [NSString stringWithFormat:@"%.1f%%",item.yValue];
对此:
NSString *percentage = [NSString stringWithFormat:@"%.1f$",item.yValue];
它应该工作。 希望能帮助到你
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.