All Projects → KennethTsang → Growingtextview

KennethTsang / Growingtextview

Licence: mit
An UITextView in Swift. Support auto growing, placeholder and length limit.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Growingtextview

Inputaccessoryview
Input Accessory View for Commenting and Chat User Interfaces built in Swift, if you like it please "☆"
Stars: ✭ 39 (-94.29%)
Mutual labels:  chat, messaging, placeholder, uitextview
Stream Chat Swift
Official iOS SDK for Stream Chat
Stars: ✭ 277 (-59.44%)
Mutual labels:  chat, messaging
Eiskaltdcpp
File sharing program using DC and ADC protocols
Stars: ✭ 277 (-59.44%)
Mutual labels:  chat, messaging
Falconmessenger
🌟🌟🌟🌟🌟 Falcon Messenger is a Fast and Beautiful cloud-based messaging app. With iOS and IPadOS Support. Available on the App Store.
Stars: ✭ 310 (-54.61%)
Mutual labels:  chat, messaging
Nio
💬 Nio is an upcoming matrix client for iOS.
Stars: ✭ 235 (-65.59%)
Mutual labels:  chat, messaging
STTextView
📝 STTextView is a light-weight library that adds a placeholder to the UITextView.
Stars: ✭ 36 (-94.73%)
Mutual labels:  placeholder, uitextview
Parrot
The next generation messenger.
Stars: ✭ 305 (-55.34%)
Mutual labels:  chat, messaging
React Discord Clone
Discord Clone using React, Node, Express, Socket-IO and Mysql
Stars: ✭ 198 (-71.01%)
Mutual labels:  chat, messaging
Rpc Websockets
JSON-RPC 2.0 implementation over WebSockets for Node.js and JavaScript/TypeScript
Stars: ✭ 344 (-49.63%)
Mutual labels:  chat, messaging
Quickblox Ios Sdk
QuickBlox iOS SDK for messaging and video calling
Stars: ✭ 373 (-45.39%)
Mutual labels:  chat, messaging
Messenger Ios Chat Swift Firestore
Messenger Clone - Real-time iOS Chat with Firebase Firestore written in Swift
Stars: ✭ 405 (-40.7%)
Mutual labels:  chat, messaging
Vuvuzela
Private messaging system that hides metadata
Stars: ✭ 2,423 (+254.76%)
Mutual labels:  chat, messaging
Chatview
This is an Android library which can be used to add chat functionality to your android application with just a few lines of code.
Stars: ✭ 211 (-69.11%)
Mutual labels:  chat, messaging
Stream Chat Flutter
Stream Chat official Flutter SDK. Build your own chat experience using Dart and Flutter.
Stars: ✭ 220 (-67.79%)
Mutual labels:  chat, messaging
Chat21 Android Sdk
Android Chat SDK built on Firebase
Stars: ✭ 204 (-70.13%)
Mutual labels:  chat, messaging
Chatsecure Ios
ChatSecure is a free and open source encrypted chat client for iOS that supports OTR and OMEMO encryption over XMPP.
Stars: ✭ 3,044 (+345.68%)
Mutual labels:  chat, messaging
Ejabberd
Robust, Ubiquitous and Massively Scalable Messaging Platform (XMPP, MQTT, SIP Server)
Stars: ✭ 5,077 (+643.34%)
Mutual labels:  chat, messaging
Chatlayout
ChatLayout is an alternative solution to MessageKit. It uses custom UICollectionViewLayout to provide you full control over the presentation as well as all the tools available in UICollectionView. It supports dynamic cells and supplementary view sizes.
Stars: ✭ 184 (-73.06%)
Mutual labels:  chat, messaging
Tindroid
Tinode chat client application for Android
Stars: ✭ 194 (-71.6%)
Mutual labels:  chat, messaging
Chatkit
Android library. Flexible components for chat UI implementation with flexible possibilities for styling, customizing and data management. Made by Stfalcon
Stars: ✭ 3,496 (+411.86%)
Mutual labels:  chat, messaging

GrowingTextView

Version License Platform Language Language Language Language

Requirements

iOS 8.0 or above

Installation

CocoaPods

GrowingTextView is available through CocoaPods. To install it, simply add the following line to your Podfile:

Swift 5.0

pod 'GrowingTextView', '0.7.2'

Swift 4.2

pod 'GrowingTextView', '0.6.1'

Swift 4.1

pod 'GrowingTextView', '~> 0.5'

Swift 3

pod 'GrowingTextView', '~> 0.4'

Swift 2.3 (Stopped update since Sep 2016)

pod 'GrowingTextView', :git => 'https://github.com/KennethTsang/GrowingTextView.git', :branch => 'swift2'

Carthage

GrowingTextView is also available through Carthage. To install it, add the following line to your Cartfile:

Swift 5.0

github "KennethTsang/GrowingTextView" ~> 0.7

Swift 4.2

github "KennethTsang/GrowingTextView" ~> 0.6

Swift 4.1

github "KennethTsang/GrowingTextView" ~> 0.5

Swift 3

github "KennethTsang/GrowingTextView" ~> 0.4

Swift 2.3 (Stopped update since Sep 2016)

github "KennethTsang/GrowingTextView" "swift2"

Manually

Copy GrowingTextView.swift into your project.

Usage

Example

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

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

Using GrowingTextview in Storyboard

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

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

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

textView.maxLength = 140
textView.trimWhiteSpaceWhenEndEditing = false
textView.placeholder = "Say something..."
textView.placeholderColor = UIColor(white: 0.8, alpha: 1.0)
textView.minHeight = 25.0
textView.maxHeight = 70.0
textView.backgroundColor = UIColor.whiteColor()
textView.layer.cornerRadius = 4.0

Animation

  1. Adopt GrowingTextViewDelegate instead of UITextViewDelegate.
  2. Implement textViewDidChangeHeight.
  3. Call layoutIfNeeded() on superview inside the animation.
class ViewController: UIViewController, GrowingTextViewDelegate {
	func textViewDidChangeHeight(_ textView: GrowingTextView, height: CGFloat) {
	   UIView.animate(withDuration: 0.2) {
	       self.view.layoutIfNeeded()
	   }
	}
}

Delegate

GrowingTextViewDelegate is inherited from UITextViewDelegate. You may use it's delegate function as a normal UITextView.

class ViewController: UIViewController, GrowingTextViewDelegate {
    func textViewDidChange(_ textView: UITextView) {
    	...
    }
    func textViewDidEndEditing(_ textView: UITextView) {
    	...
    }
}

Check out UITextViewDelegate here: https://developer.apple.com/reference/uikit/uitextviewdelegate

Author

Kenneth Tsang, [email protected]

License

GrowingTextView is available under the MIT license. See the LICENSE file for more info.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].