views:

58

answers:

2

I have a vertically-scrolling UITextView that fills the width of the screen. I need the text view to have margins (contentInset) of 20 pixels on the left and the right. But for some reason, I can't get the right-hand margin to work, either in Interface Builder or in XCode.

The reason I can't just make the text view narrower is because I am adding a subview which needs to run the full width of the screen. Also, I can't turn subview clipping off, because it plays havoc with a load of other elements on the screen.

Anyone know why the contentInset property is not affecting the right margin?

Thanks!

A: 

view.setPadding(left,top,right,bottom);

Set the right padding to 20, the rest to 0.

fredley
A: 

You could add an intermediate view that can be the superview to your text view and what was previously it's subview.

New View with Frame(0,0,width,height)
 ->TextView with Frame(20,0,width-20,height)     
 ->Subview with Frame(0,0,width,height)
DHamrick
This won't make the subview scroll with the text view, which may be what is desired.I would've expected UIScrollView.contentInset to work, though.
tc.