文字被表格挡住无法正常显示

有一个柱状图标,需要每个柱形图都显示名字,但是名字过长的时候就会被盖住,怎么解决?我希望能根据字体长度自动调整。

实现代码:

 NSString *percentage = [NSString stringWithFormat:@"%@",item.myTopNameStr];
 [percentage drawAtPoint:CGPointMake(_histogramStartX + 5,_xaxisStart.y - _ySpacingScale*item.yValue - 25) forWidth:80 withFont:[UIFont boldSystemFontOfSize:10] lineBreakMode:NSLineBreakByClipping];

效果图:

柱状图

NSString * percentage = [NSString stringWithFormat:@"%@",item.myTopNameStr];
CGSize percentageSize = [percentage sizeWithFont:[UIFont boldSystemFontOfSize:10] forWidth:80 lineBreakMode:UILineBreakModeWordWrap];

[percentage drawInRect:CGRectMake(_histogramStartX + 5,_xaxisStart.y - _ySpacingScale*item.yValue - 25, percentageSize.width, percentageSize.height) withFont:[UIFont boldSystemFontOfSize:10] lineBreakMode:UILineBreakModeWordWrap alignment:NSTextAlignmentLeft];