Adding left margin to UITextView

前端 未结 6 717
臣服心动
臣服心动 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 18:05

    Remember that for iOS 7 there a special property called

    textContainerInset The inset of the text container's layout area within the text view's content area.

    @property(nonatomic, assign) UIEdgeInsets textContainerInset

    This property provides text margins for text laid out in the text view.

    Availability Available in iOS 7.0 and later. Declared In UITextView.h

    in iOS 6 the contentInset is doing the job. I personally encountered this problem. Everything ended up with:

    if (isIOS7()) {
        textView.textContainerInset = UIEdgeInsetsMake(0, 10, 0, 10);
    } else {
        textView.contentInset = UIEdgeInsetsMake(0, 10, 0, 10);
    }
    

提交回复
热议问题