Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a margin in UITextView?

Tags:

I'm currently developing a simple text-editing app for iPad. I want to set left/right margins like the attached picture. Just adding UITextView into another UIView with larger width won't work because a scroll indicator won't be properly located.

Instead of UIView, I added UITextView into UIScrollView, and it works almost fine. But they sometimes show strange behaviors, and UITextViewDelegate doesn't work with my UIViewController.

Is there any way to set left/right margins only using UITextView? Thank you.

alt text

like image 240
pnmn Avatar asked Dec 02 '10 14:12

pnmn


1 Answers

You can use the property textContainerInset

Following the example of George Green:

myTextView.textContainerInset = UIEdgeInsetsMake(0.0f, 10.0f, 0.0f, 10.0f); 
like image 131
NES8 Avatar answered Oct 15 '22 07:10

NES8