Reputation: 3676
I'm trying to shift the text in my UITextView right by 20 pixels to create a text indent using the code below
[textview setContentInset:UIEdgeInsetsMake(0, 20, 0,-20)];
But this is cutting off the right hand side of my text as shown in the screenshot. Can any help me stop this happening please
Upvotes: 2
Views: 2128
Reputation: 314
I couldn't find a solution to your problem even by subclassing UITextView and blocking setContentSize which seemed to be the problem.
[textview setContentInset:UIEdgeInsetsMake(0, 20, 0, rightInset)];
No matter what is the value of the rightInset the text is always clipped. Something is always redrawing text so that it fits the frame width of the text view. But I am wondering why do you need to set the inset? Can't you just set the background of the UITextView object to clear color and position it properly on your background view to get the illusion of indentation?
Upvotes: 1
Reputation: 9913
I think your edge insets are a bit off. Edge insets work towards the middle of the rectangle. For the right inset you should try 20 rather than -20.
[textview setContentInset:UIEdgeInsetsMake(0, 20, 0, 20)];
Upvotes: 2