1
CPTAnnotationでNSAttributedStringを改行して使用しようとしています。 以下のコードを使用すると、「firstString ...」だけが表示されます。 \ n記号を削除すると、両方の文字列が正しく表示されます(適切なサイズと色)が、1行に表示されます。CPTTextLayer - 複数行NSAttributedString
注釈で使用されるCPTTextLayerで、labelOnlineLine = 0(改行を有効にする)と同様のものを使用できますか?
NSMutableAttributedString* finalString = [firstAttrStr mutableCopy];
NSMutableAttributedString *newLineAttrStr = [[NSMutableAttributedString alloc]initWithString:@"\n"];
[finalLabel appendAttributedString:newLineAttrStr];
[finalLabel appendAttributedString:secondAttrStr];
//additional setup in here
CPTTextLayer *textLayer = [[CPTTextLayer alloc] initWithAttributedText:finalLabel];
textLayer.fill = [CPTFill fillWithColor:[CPTColor whiteColor]];
textLayer.cornerRadius = 3.0;
textLayer.paddingLeft = 0.5;
textLayer.paddingTop = 0.5;
textLayer.paddingRight = 0.5;
textLayer.paddingBottom = 0.5;
textLayer.hidden = NO;
//add shadow
textLayer.masksToBounds = NO;
textLayer.shadowOffset = CGSizeMake(0, 0);
textLayer.shadowRadius = 5;
textLayer.shadowOpacity = 0.3;
_highlightAnnotation = [[CPTPlotSpaceAnnotation alloc] initWithPlotSpace:plotSpace anchorPlotPoint:@[middlePoint, yAnnotationPosition]];
[_highLightPlot addAnnotation:_highlightAnnotation];
CPTTextLayer *textLayer = [[CPTTextLayer alloc] initWithAttributedText:finalString];
_highlightAnnotation.contentLayer = textLayer;
それはそのように見えます:エリックの提案に
注釈はどこに表示されていますか? 2行目がプロット領域の端で切り取られる可能性はありますか? Core Plotは、ラベル全体が表示されるように自動的にレイアウトを調整しません。 –
私はスクリーンショットを追加しました。間違いなくプロット領域で切り取られます。 – izik461
使用しているCore Plotのバージョンは?これは、シミュレータとデバイスの両方で発生するのでしょうか? iOSのどのバージョンでテストしていますか? –