Latest 1.1
Homepage https://github.com/HansPinckaers/GrowingTextView
License MIT
Platforms ios , requires ARC
Authors

Multi-line/Autoresizing UITextView similar as in the SMS-app. The example project mimicks the look of Apple’s SMS-app.

Screenshot

Properties

int maxNumberOfLines; // Stops growing at this amount of lines.
int minNumberOfLines; // Starts growing at this amount of lines.
int maxHeight; // Specify the maximum height in points instead of lines.
int minHeight; // Specify the minimum height in points instead of lines.
BOOL animateHeightChange; // Animate the growing
NSTimeInterval animationDuration; // Adjust the duration of the growth animation.

UITextView borrowed properties

NSString *text;
UIFont *font;
UIColor *textColor;
NSTextAlignment textAlignment;
NSRange selectedRange;
BOOL editable;
UIDataDetectorTypes dataDetectorTypes;
UIReturnKeyType returnKeyType;

If you want to set other UITextView properties, use .internalTextView

Delegate methods

-(BOOL)growingTextViewShouldBeginEditing:(HPGrowingTextView *)growingTextView;
-(BOOL)growingTextViewShouldEndEditing:(HPGrowingTextView *)growingTextView;

-(void)growingTextViewDidBeginEditing:(HPGrowingTextView *)growingTextView;
-(void)growingTextViewDidEndEditing:(HPGrowingTextView *)growingTextView;

-(BOOL)growingTextView:(HPGrowingTextView *)growingTextView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text;
-(void)growingTextViewDidChange:(HPGrowingTextView *)growingTextView;

// Called WITHIN animation block!
-(void)growingTextView:(HPGrowingTextView *)growingTextView willChangeHeight:(float)height;

// Called after animation
-(void)growingTextView:(HPGrowingTextView *)growingTextView didChangeHeight:(float)height;

-(void)growingTextViewDidChangeSelection:(HPGrowingTextView *)growingTextView;
-(BOOL)growingTextViewShouldReturn:(HPGrowingTextView *)growingTextView;

For more info, see blogpost: http://www.hanspinckaers.com/multi-line-uitextview-similar-to-sms

Latest podspec

{
    "name": "HPGrowingTextView",
    "version": "1.1",
    "summary": "Multi-line/Autoresizing UITextView similar to SMS-app.",
    "description": "An UITextView which grows/shrinks with the text and starts scrolling when the content reaches a certain number of lines.",
    "homepage": "https://github.com/HansPinckaers/GrowingTextView",
    "license": {
        "type": "MIT",
        "file": "LICENSE.txt"
    },
    "authors": {
        "Hans Pinckaers": "[email protected]"
    },
    "source": {
        "git": "https://github.com/HansPinckaers/GrowingTextView.git",
        "tag": "1.1"
    },
    "platforms": {
        "ios": null
    },
    "source_files": [
        "Classes",
        "class/**/*.{h,m}"
    ],
    "requires_arc": true
}

Pin It on Pinterest

Share This