1
如果文本長度大於50個字符,我想在兩行中顯示CPTAxisLabel。我怎樣才能做到這一點?我看到一種方法可以在矩形中繪製一個字符串。但我不知道如何調用這個方法。 如果下面的方法是這個解決方案,請幫助我如何調用這個。否則,請另行提供。如何在iphone sdk中使用corePlot庫將CPTAxisLabel打包成兩行?
預先感謝 - (空)drawInRect:(的CGRect)RECT withTextStyle:(CPTTextStyle *)風格inContext的:(CGContextRef)方面 {
如果(style.color ==無)回報;
CGContextSaveGState(context);
CGColorRef textColor = style.color.cgColor;
CGContextSetStrokeColorWithColor(context, textColor);
CGContextSetFillColorWithColor(context, textColor);
CPTPushCGContext(context);
UIFont *theFont = [UIFont fontWithName:style.fontName size:style.fontSize];
[self drawInRect:rect
withFont:theFont
lineBreakMode:UILineBreakModeWordWrap
alignment:(UITextAlignment)style.textAlignment];
CGContextRestoreGState(context);
CPTPopCGContext();
}
我沒有自動獲取多行文本。我有長度爲80個字符的切片標籤,但它只顯示剩餘50個字符正在切斷。如果我想添加'\ n',則意味着我必須計算文本長度,並且當長度超過50時,我必須添加\ n。如果有其他解決方案,請提供給我。 –