LoginSignup
29
27

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()]
29
27
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
29
27