UITextView is a good control for displaying text in iOS. It is a scrolling view that presents formatted text on demand. It performs all the work of laying out the text and responding to changes in text, so you can focus on the content of the text. In the iPhone software keyboard, a UITextView provides the keyboard with its text. In iOS 4, UITextView makes it easy to automatically resize itself when the keyboard is displayed. In addition, in iOS 4, the UITextView class supports two new properties, textContainer and textContainerInset, that allow you to get and set the frame of the text container, which encloses the text but not the text container itself.

The UITextView is an iOS text view that is used for displaying pieces of text and associated images. UITextView is a subclass of UIView and a member of UITextInput protocol, which makes it very versatile. As the name implies, UITextView focuses on text content rather than presenting the entire body of an HTML document.

A look at the growth

UITextView in Swift. Supports car expansion, placeholders and length restriction.

Requirements

iOS 8.0 or higher

Setting

CocoaPods

GrowingTextView is available through CocoaPods. To install
, 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 (update stopped since september 2016)

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

Carthago

GrowingTextView is also available from
Carthage. To install it, add the following line
to your cart file:

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 (update stopped since september 2016)

github KennethTsang/GrowingTextView swift2

Manual

Copy GrowingTextView.swift to your project.

Use

Example

GrowingTextview is simply a text viewer. Download a sample to see how you can use it as an input toolbar like in other instant messaging applications.

Use of the GrowingTextview software

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

Using GrowingTextview in the storyboard

  1. Drag a TextView onto the storyboard and drop it there.
  2. Define the class GrowingTextView.
  3. Define a delegation to the view controller.
auto-adjustScrollViewInsets

Sometimes the view controller does not automatically and correctly configure the insertion of the text view. To avoid this, set the value false for automaticallyAdjustsScrollViewInsets.

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

Adjustment

Parameter Type Description Standard
maxLength Int Maximum text length. Text that exceeds the limit is truncated. 0 means there is no limit. 0
trimWhiteSpaceWhenEndEditing Boolean Cuts spaces and newline characters when you are done editing in the text area. really
Filling Thong? Text on the support. zero
placeholderColor UIColor The color of the filler text. UIColor(white:0.8, alpha:1.0)
allocated place holder NSAttributedString ? Substitute text assigned. zero
minHeight CGFloat Minimum height of the text window. 0.0
maxHeight CGFloat Maximum height of the text field. 0.0

Examples

textView.maxLength = 140
textView.trimWhiteSpaceWhenEndEditing = false
textView.placeholder = Sag 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. Take GrowingTextViewDelegate instead of UITextViewDelegate.
  2. Implements the textViewDidChangeHeight function.
  3. Call layoutIfNeeded() in the super view within the animation.

ViewController class: UIViewController, GrowingTextViewDelegate {
func textViewDidChangeHeight(_ textView : GrowingTextView, height : CGFloat) {
UIView.animate(withDuration : 0.2) {
self.view.layoutIfNeeded()
}
}
}

Delegate

GrowingTextViewDelegate is inherited from UITextViewDelegate. You can use the delegate function as a normal UITextView.

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

}
func textViewDidEndEditing(_ textView : UITextView) {

}
}

For more information on ITUextViewDelegate, visit https://developer.apple.com/reference/uikit/uitextviewdelegate.

Author

Kenneth Zang, [email protected].

GitHub

https://github.com/KennethTsang/GrowingTextView

This source has been very much helpful in doing our research. Read more about change textview height programmatically swift and let us know what you think.

uitextview mentions swift githubuitextfield placeholder animation swiftuitextview placeholder swiftnextgrowingtextviewcustom uitextfield swift githubread more textview swift github,People also search for,Privacy settings,How Search works,uitextview mentions swift github,uitextfield placeholder animation swift,uitextview placeholder swift,change textview height programmatically swift,nextgrowingtextview,custom uitextfield swift github,read more textview swift github,floating textfield in swift github

You May Also Like

What To Do When Windows 10 Won’t Boot

Normally, a Windows 10 computer starts up as soon as you press…

How to configure NAT to change the port for the server to go out to the internet with IP Wan as a dynamic IP –

Having a dynamic IP, this blog can help you with your current…

17 Solutions To Fix Windows Code 43 Error

Windows has a really annoying service error called “Code 43” that only…

How to configure Captive Portal to authenticate users when accessing the internet with users synchronized from AD –

Active Directory can be a pain to configure and manage. However, there…