Adding left margin to UITextView

前端 未结 6 783
臣服心动
臣服心动 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:47

    UITextView is internally implemented using a web view. These internals uses allot of undocumented tricks, that also changes between OS updates. One of these tricks is to time and again reset the contentInsets property. When and why is not documented, by I have learned that any changes to the layout of the text view can/will trigger this reset.

    My first advice would be to not try to tweak the insets of the text view. It is just to fragile, and will probably break in the future.

    If you really insist anyway then I would subclass UITextView, override -[UITextView layoutSubviews] and force new insets there.

    In either case I would go to http://bugreport.apple.com and report the current behavior as serious bug.

提交回复
热议问题