Adding left margin to UITextView

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

    If you only want to move the text, try

    [textView setContentInset:UIEdgeInsetsMake(<#CGFloat top#>, <#CGFloat left#>, <#CGFloat bottom#>, <#CGFloat right#>)];
    

    Where a positive number moves the "text frame" towards the middle, a negative moves it out from the middle.

    For example, [textView setContentInset:UIEdgeInsetsMake(0, 20, 0,-20)], will move the text 20 pixels to the right!

提交回复
热议问题