30
28

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

UITextViewのURLリンクの色をカスタマイズする方法

Posted at

・編集不可にする。
・リンクとして認識させる
・色の指定(デフォルトは青)

Cbjective-C

// 編集不可にする
textView.editable = false

// textViewのtextにURLの文字列があればリンクとして認識する
textView.dataDetectorTypes = UIDataDetectorTypeLink;

// リンクの色を指定する
textView.linkTextAttributes = @{NSForegroundColorAttributeName: [UIColor blueColor]};
Swift

// 編集不可にする
textView.editable = false

// textViewのtextにURLの文字列があればリンクとして認識する
textView.dataDetectorTypes = .Link
        
// リンクの色を指定する
textView.linkTextAttributes = [NSForegroundColorAttributeName:UIColor.blueColor()]
30
28
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
30
28

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?