Adding left margin to UITextView

前端 未结 6 714
臣服心动
臣服心动 2021-02-05 17:25

I\'m trying to add a left margin to a UITextView.

I\'ve tried setting the property contentInset, see below:

UITextView *textView = [[UITextView alloc] in         


        
6条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-05 17:59

    You can try this code below with Swift 3.0

    // Align the text to the left edge of textContainer
    textView.textContainer.lineFragmentPadding = 16
    // Align the text with the top of textContainer
    textView.textContainerInset = UIEdgeInsets.zero
    

    It works for me.

提交回复
热议问题