Created
September 14, 2013 19:27
-
-
Save Lejdborg/6564851 to your computer and use it in GitHub Desktop.
How to add left and right margins to a UITextView...
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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