1
1

More than 1 year has passed since last update.

【Swift】UILabelをUITextViewに変更する際の注意点(メモ)

Last updated at Posted at 2020-09-15

UILabelで作っていたが、後々ハイパーリンクにしたいなどで、
UILabel→UITextViewに変更しなくては。。などというケースの注意点メモ。。。

環境

  • Xcode: 11.3.1
  • Swift5

・UITextViewのスクロールをオフ

オートレイアウトを使用している場合、スクロールがONだと高さが計算されないので、
以下コードを追記

    textView.isScrollEnabled = false

・UITextViewの余白(padding)を削除

実際に文字を表示してみると上下に余白ができてしまう。
以下コードを追記

    textView.textContainerInset = .zero
1
1
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
1
1