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
The ONLY thing worked for me is by sub-classing the UITextView and overriding the following method:
- (id)styleString
{
return [[super styleString] stringByAppendingString:@"; line-height: 1.6em;margin-right: 30px; margin-left: 45px; margin-top: 20px;"];
}
Apparently; you can tweak the margin-left, margin-top & whatever you want ;)
The suggestion about placing the UITextView in a larger UIView didn't work for me as I needed to scrollable lines in the background of UITextView, I used the following open-source project to do that: https://github.com/aahsanali/NoteView
Also, the following solution didn't help me at all:
[textView setContentInset:UIEdgeInsetsMake(0, 20, 0,-20)]
As it wasn't wrapping text correctly.
I hope this solution helps as I literally spent a week digging into this simple UI tweak!