0

UILabel に太字、斜体、リンクを含む HTML テキストを配置する必要があります。リンクを使用するNSAttributedStringと、クリックできなくなります。リンクを使用するTTTAttributedLabelとクリック可能になりますが、書式設定 (太字と斜体) が表示されません。

この問題は私を夢中にさせます!アイデア?

4

1 に答える 1

0

TTTAttributedLabel を使用して、リンクの書式設定を機能させることができます。たとえば、これはリンクを青く色付けし、下線を付けます (Swift の場合):

let bodyLabel: TTTAttributedLabel

let content = "TTTAttributedLabel will detect http://example.com"
let attributedContent = NSMutableAttributedString(string: content)

// add some attributes as you need to the attributed string, then...

let blueLinks = [NSForegroundColorAttributeName: UIColor.blueColor()]

bodyLabel.enabledTextCheckingTypes = NSTextCheckingType.Link.rawValue
bodyLabel.linkAttributes = blueLinks

bodyLabel.setText(attributedContent)
于 2015-09-30T21:58:16.397 に答える