UITextViewの文字周りの余白を変更する

UITextViewの文字周りの余白を変更する iOS

UITextViewの文字周りの余白を広げる

UITextViewの文字の周りを広げるには textContainerInset を使用する。

textView.textContainerInset = UIEdgeInsetsMake(20, 20, 20, 20)
textView.sizeToFit()

参考記事

UITextViewの文字周りの余白を消す

逆にUITextViewの文字の周りの余白を消す場合には以下のようにする。

textView.textContainerInset = UIEdgeInsetsZero
textView.textContainer.lineFragmentPadding = 0 

参考記事