0
UITextViewまたはUILabel内の各リンクのスタイルを変更したいと思います。私は現在、リンクでUITextViewsを使用していますが、URLが紫色に表示され、ユーザー名が黒く表示されるようにします。私はTTTAttributedLabelも調べましたが、これを達成する方法を見つけることができないようです。UITextView/UILabel Swiftのリンクごとに異なるテキスト属性
textView.linkTextAttributes = [NSForegroundColorAttributeName: UIColor.orange]
attributedString.setAttributes([NSLinkAttributeName: url, range: range)
attributedString.addAttributes([NSForegroundColorAttributeName: UIColor.purple], range: range)
私が試した上記の例では、リンクはオレンジで、紫色ではありません。 linkTextAttributesを設定しないと、リンクは青色になります。 linkTextAttributesをリンクごとに異なる属性で上書きするにはどうすればよいですか?
このリンクはあなたを助けることができます:[http://stackoverflow.com/questions/28361072/change-the-color-of-a-link-in-an-nsmutableattributedstring](http://stackoverflow.com/質問/ 28361072/change-the-a-link-in-an-nsmutableattributedstring)[http://stackoverflow.com/questions/13405513/change-uitextview-hyperlink-color/21027340#21027340](http: //stackoverflow.com/questions/13405513/change-uitextview-hyperlink-color/21027340#21027340) –
ありがとうございますが、私はすでにlinkTextAttributesを試しています。私の質問は、リンクごとに異なる属性についてです。実際、私の質問はあなたの最初のリンクのコメントで尋ねられましたが、回答はありませんでした。http://stackoverflow.com/questions/28361072/change-the-color-of-a-link-in-an-nsmutableattributedstring# comment62635278_32222702 @RenatoIoshida – Josh