cannyboy
cannyboy

Reputation: 24436

Limiting UITextView to one line

Is there a way to limit UITextView to one line, whereby I can fill it with any amount of text and it will resize horizontally to match: like so:

-----------
| cheese  |
-----------

... when filled with longer text becomes

--------------------------
| the last man on earth  |
--------------------------

(the lines indicate the edges of the UITextView)

Upvotes: 4

Views: 5616

Answers (1)

iMeMyself
iMeMyself

Reputation: 1649

this can be achieved by inheriting UITextView class as

@interface InputTextView : UITextView
@end

@implementation InputTextView

/*************************************************
* fixes the issue with single lined uitextview
*************************************************/
- (UIEdgeInsets) contentInset { return UIEdgeInsetsZero; }

@end

for further reference go-through here

Upvotes: 1

Related Questions