IOS - remove ALL padding from UITextView
ios, padding, uitextview
Solution
Although it is iOS 7 only, an extremely clean solution is to set the textView's textContainerInsets as such:
[textView setTextContainerInset:UIEdgeInsetsZero];
textView.textContainer.lineFragmentPadding = 0; // to remove left padding
This will effectively remove all padding (insets) around the text inside the text view. If your deployment target is iOS 7+ then this is the best solution thus far.
Problem
There are many great examples on SO to remove the left padding of a UITextView. How to lose margin/padding in UITextView? However, I need to remove the right padding too. I have tried... ``` [tv setContentInset: UIEdgeInsetsMake(-4,-8,-8,-X)];//where X is any integer ``` and just about every other permutation of the last two values to remove the padding and nothing seems to work. Have also tried ``` [tv sizeToFit]; [tv setTextAlignment:[NSTextAlignmentRight]]; ``` The following Text in the Textview says "00"