adit
adit

Reputation: 33644

UITextView with bottom padding

So I wanted to create something like this:

enter image description here

Basically I wanted to have that bottom padding of around 20 px of height for that text count. I've tried setting the inset, but it doesn't work.. how can I do this so that there will always be a 20 px at the bottom of the text view?

Here's what I did:

 [self.comments_ setScrollIndicatorInsets:UIEdgeInsetsMake(0, 0, 25, 0)];
    [self.comments_ setContentInset:UIEdgeInsetsMake(0, 0, 25, 0)];

but I am still getting text on that bottom padding when it overflows.. any idea? This is from the float app reader

Upvotes: 2

Views: 721

Answers (1)

Bojan Dimovski
Bojan Dimovski

Reputation: 1216

Try wrapping your UITextView within a UIView with the padded dimensions. It would look something like this:

UITextView *textView = [[[UITextView alloc] initWithFrame:CGRectMake(5, 5, 100, 50)] autorelease];
textView.text = @"Lorem ipsum";
textView.backgroundColor = [UIColor clearColor];

UIView *view = [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 110, 80)] autorelease];
[view addSubview:textView];

This would pad the text view 5px on each side, except for the 25px bottom padding. Maybe I missed some detail, but the frames part is the one that should help you.

Upvotes: 1

Related Questions