0

https://github.com/honcheng/RTLabelを使用してリッチ テキスト ラベルを取得しようとしていますが、当面の目標は「Hello, world!」を表示することです。

私のコードは次のとおりです。

        UIImageView *noteImage = [[UIImageView alloc] initWithFrame:bounds];
        noteImage.image = image;
        [self.view addSubview:noteImage];
        CJSHCardView *noteView = [[CJSHCardView alloc] initWithImage:image];
        [noteView setFrame:CGRectMake(100 * i, 20, 100 * scale, 100 * scale)];
        noteView.transform = CGAffineTransformScale(noteView.transform, scale_x, scale_y);
        NSString *text = @"Hello, world!";
        RTLabel *label = [[RTLabel alloc] initWithFrame:CGRectMake(100 * i, 20, 100 * scale, 100 * scale)];
        [noteImage addSubview:label];
        [label setText:text];

最後から2番目の行でnoteImageとnoteViewの両方を試しました。四角形は、正しく表示されている元の画像と同じ寸法です。ただし、私が試したアプローチはどれも、背景として noteImage / noteView の上にラベルを表示するのに適しているようには見えません。

ラベル (できればリッチ テキストをサポートするもの) を背景として使用する画像の上に表示する適切な方法は何ですか?

4

1 に答える 1