Skip to content

Instantly share code, notes, and snippets.

@Lejdborg
Created September 14, 2013 19:27
Show Gist options
  • Save Lejdborg/6564851 to your computer and use it in GitHub Desktop.
Save Lejdborg/6564851 to your computer and use it in GitHub Desktop.
How to add left and right margins to a UITextView...
float padding = 10.0;
NSMutableParagraphStyle *editorParagraphStyle = [NSMutableParagraphStyle new];
[editorParagraphStyle setHeadIndent:padding];
[editorParagraphStyle setFirstLineHeadIndent:padding];
[editorParagraphStyle setTailIndent:-padding];
NSDictionary *textAttributes = @{
NSFontAttributeName: [UIFont fontWithName:@"Helvetica" size:14],
NSParagraphStyleAttributeName: editorParagraphStyle
};
[self.textView setAttributedText:[[NSAttributedString alloc] initWithString:self.textView.text
attributes:textAttributes]];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment