<commit_before># GrowingTextView

[![Version](https://img.shields.io/cocoapods/v/GrowingTextView.svg?style=flat)](http://cocoapods.org/pods/GrowingTextView)
[![License](https://img.shields.io/cocoapods/l/GrowingTextView.svg?style=flat)](http://cocoapods.org/pods/GrowingTextView)
[![Platform](https://img.shields.io/cocoapods/p/GrowingTextView.svg?style=flat)](http://cocoapods.org/pods/GrowingTextView)
[![Language](https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat)](http://cocoapods.org/pods/GrowingTextView)
[![Language](https://img.shields.io/badge/Swift-4.0-orange.svg?style=flat)](http://cocoapods.org/pods/GrowingTextView)

<img src="DEMO.gif" border=1 style="border-color:#eeeeee">

## Requirements

iOS 8.0 or above

## Installation

#### CocoaPods

GrowingTextView is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:

Swift 4<br>

```ruby
pod 'GrowingTextView', '~> 0.5.4'
```

Swift 3<br>
```ruby
pod 'GrowingTextView', '~> 0.4.0'
```

Swift 2.3 (Stopped update since Sep 2016)<br>
```ruby
pod 'GrowingTextView', :git => 'https://github.com/KennethTsang/GrowingTextView.git', :branch => 'swift2'
```

#### Manually

Copy `GrowingTextView.swift` into your project.

## Usage

**Example**<br>

GrowingTextview is just a textview, download the example to see how to use it as a input toolbar like other instant messaging apps.

**Using GrowingTextview programmatically**<br>

```swift
let textView = GrowingTextView()
textView.delegate = self
addSubview(textView)
```

**Using GrowingTextview in Storyboard**<br>

1. Drag a TextView into Storyboard.
2. Set class to "GrowingTextView".
3. Set delegate to it's view controller.


##### automaticallyAdjustsScrollViewInsets<br>

Sometime the view controller may incorrectly adjust the inset of textview automatically. To avoid this, set `automaticallyAdjustsScrollViewInsets` to `false`

```swift
override func viewDidLoad() {
	super.viewDidLoad()
	automaticallyAdjustsScrollViewInsets = false
}
```

## Customization

| Parameter                      | Type                | Description                              | Default                         |
| ------------------------------ | ------------------- | ---------------------------------------- | ------------------------------- |
| *maxLength*                    | Int                 | Maximum text length. Exceeded text will be trimmed. 0 means no limit. | *0*                             |
| *trimWhiteSpaceWhenEndEditing* | Bool                | Trim white space and new line characters when textview did end editing. | *true*                          |
| *placeholder*                  | String?             | PlaceHolder text.                        | *nil*                           |
| *placeholderColor*             | UIColor             | PlaceHolder text color.                  | UIColor(white: 0.8, alpha: 1.0) |
| *attributedPlaceHolder*        | NSAttributedString? | Attributed PlaceHolder text.             | *nil*                           |
| *minHeight*                    | CGFloat             | Minimum height of textview.              | *0.0*                           |
| *maxHeight*                    | CGFloat             | Maximum height of textview.              | *0.0*                           |

#### Examples

```swift
textView.maxLength = 140
textView.trimWhiteSpaceWhenEndEditing = false<commit_msg>Sync with corrected "placeholder" word.<commit_after># GrowingTextView

[![Version](https://img.shields.io/cocoapods/v/GrowingTextView.svg?style=flat)](http://cocoapods.org/pods/GrowingTextView)
[![License](https://img.shields.io/cocoapods/l/GrowingTextView.svg?style=flat)](http://cocoapods.org/pods/GrowingTextView)
[![Platform](https://img.shields.io/cocoapods/p/GrowingTextView.svg?style=flat)](http://cocoapods.org/pods/GrowingTextView)
[![Language](https://img.shields.io/badge/Swift-3.0-orange.svg?style=flat)](http://cocoapods.org/pods/GrowingTextView)
[![Language](https://img.shields.io/badge/Swift-4.0-orange.svg?style=flat)](http://cocoapods.org/pods/GrowingTextView)

<img src="DEMO.gif" border=1 style="border-color:#eeeeee">

## Requirements

iOS 8.0 or above

## Installation

#### CocoaPods

GrowingTextView is available through [CocoaPods](http://cocoapods.org). To install
it, simply add the following line to your Podfile:

Swift 4<br>

```ruby
pod 'GrowingTextView', '~> 0.5.4'
```

Swift 3<br>
```ruby
pod 'GrowingTextView', '~> 0.4.0'
```

Swift 2.3 (Stopped update since Sep 2016)<br>
```ruby
pod 'GrowingTextView', :git => 'https://github.com/KennethTsang/GrowingTextView.git', :branch => 'swift2'
```

#### Manually

Copy `GrowingTextView.swift` into your project.

## Usage

**Example**<br>

GrowingTextview is just a textview, download the example to see how to use it as a input toolbar like other instant messaging apps.

**Using GrowingTextview programmatically**<br>

```swift
let textView = GrowingTextView()
textView.delegate = self
addSubview(textView)
```

**Using GrowingTextview in Storyboard**<br>

1. Drag a TextView into Storyboard.
2. Set class to "GrowingTextView".
3. Set delegate to it's view controller.


##### automaticallyAdjustsScrollViewInsets<br>

Sometime the view controller may incorrectly adjust the inset of textview automatically. To avoid this, set `automaticallyAdjustsScrollViewInsets` to `false`

```swift
override func viewDidLoad() {
	super.viewDidLoad()
	automaticallyAdjustsScrollViewInsets = false
}
```

## Customization

| Parameter                      | Type                | Description                              | Default                         |
| ------------------------------ | ------------------- | ---------------------------------------- | ------------------------------- |
| *maxLength*                    | Int                 | Maximum text length. Exceeded text will be trimmed. 0 means no limit. | *0*                             |
| *trimWhiteSpaceWhenEndEditing* | Bool                | Trim white space and new line characters when textview did end editing. | *true*                          |
| *placeholder*                  | String?             | Placeholder text.                        | *nil*                           |
| *placeholderColor*             | UIColor             | Placeholder text color.                  | UIColor(white: 0.8, alpha: 1.0) |
| *attributedPlaceholder*        | NSAttributedString? | Attributed Placeholder text.             | *nil*                           |
| *minHeight*                    | CGFloat             | Minimum height of textview.              | *0.0*                           |
| *maxHeight*                    | CGFloat             | Maximum height of textview.              | *0.0*                           |

#### Examples

```swift
textView.maxLength = 140
textView.trimWhiteSpaceWhenEndEditing = false
{'fraction_non_alphanumeric': 0.1575043630017452, 'fraction_numerical': 0.011052937754508435, 'mean_word_length': 2.2438679245283017, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 27, 'https://': 12, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 8, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1100705', 'n_tokens_mistral': 2165, 'n_tokens_neox': 1942, 'n_words': 453}