Add “padding” to a UITextView

前端 未结 8 705
渐次进展
渐次进展 2021-01-31 14:19

as the title says i am trying to add padding-like behavior to a UITextView. The textview is generated when the view is pushed inside my navigation controller and the following c

8条回答
  •  南旧
    南旧 (楼主)
    2021-01-31 14:50

    Simply create an extension of UITextView using Container Edge Inset as following:

    extension UITextView {
        func leftSpace() {
            self.textContainerInset = UIEdgeInsets(top: 4, left: 6, bottom: 4, right: 4)
        }
    }
    

    and use it like:

    let textView = UITextView()
    textView. leftSpace() 
    

提交回复
热议问题