Skip to main content
denoise https://meta.stackexchange.com/q/131009/997587
Source Link
starball
  • 59.5k
  • 52
  • 313
  • 1k

Using Objective-C I have done it just with

[self.textView setTextContainerInset:UIEdgeInsetsMake(0, 12, 0, 12)]; 

For Swift you can use:

textview.contentInset = UIEdgeInsets(top: 0, left: 12, bottom: 0, right: 12) 

You can also create a Swift Extension (Suggested by chowdhury-md-rajib-sarwar) here:

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

}

And then use

let textView = UITextView() textView.leftSpace() 

Hope this helps, Mário

Using Objective-C I have done it just with

[self.textView setTextContainerInset:UIEdgeInsetsMake(0, 12, 0, 12)]; 

For Swift you can use:

textview.contentInset = UIEdgeInsets(top: 0, left: 12, bottom: 0, right: 12) 

You can also create a Swift Extension (Suggested by chowdhury-md-rajib-sarwar) here:

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

}

And then use

let textView = UITextView() textView.leftSpace() 

Hope this helps, Mário

Using Objective-C I have done it just with

[self.textView setTextContainerInset:UIEdgeInsetsMake(0, 12, 0, 12)]; 

For Swift you can use:

textview.contentInset = UIEdgeInsets(top: 0, left: 12, bottom: 0, right: 12) 

You can also create a Swift Extension (Suggested by chowdhury-md-rajib-sarwar) here:

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

}

And then use

let textView = UITextView() textView.leftSpace() 
Added swift
Source Link
Mário Carvalho
  • 3.1k
  • 4
  • 25
  • 27

Using iOS7Objective-C I have done it just with

[self.textView setTextContainerInset:UIEdgeInsetsMake(0, 12, 0, 12)]; 

For Swift you can use:

textview.contentInset = UIEdgeInsets(top: 0, left: 12, bottom: 0, right: 12) 

You can also create a Swift Extension (Suggested by chowdhury-md-rajib-sarwar) here:

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

}

And then use

let textView = UITextView() textView.leftSpace()  

Hope this helps, Mário

Using iOS7 I have done it just with

[self.textView setTextContainerInset:UIEdgeInsetsMake(0, 12, 0, 12)]; 

Hope this helps, Mário

Using Objective-C I have done it just with

[self.textView setTextContainerInset:UIEdgeInsetsMake(0, 12, 0, 12)]; 

For Swift you can use:

textview.contentInset = UIEdgeInsets(top: 0, left: 12, bottom: 0, right: 12) 

You can also create a Swift Extension (Suggested by chowdhury-md-rajib-sarwar) here:

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

}

And then use

let textView = UITextView() textView.leftSpace()  

Hope this helps, Mário

Source Link
Mário Carvalho
  • 3.1k
  • 4
  • 25
  • 27

Using iOS7 I have done it just with

[self.textView setTextContainerInset:UIEdgeInsetsMake(0, 12, 0, 12)]; 

Hope this helps, Mário