PlaceholderUITextView is a simple subclass from UITextView with multiple line placeholder.


  • Xcode 10 or later
  • iOS 10.0 or later
  • Swift 4.2 or later

Getting Started


Install with CocoaPods by adding the following to your Podfile:

platform :ios, '10.0'
pod 'PlaceholderUITextView'

Swift Package Manager

Install with Swift Package Manager by adding the following to your Package.swift:

dependencies: [
.package(url: "", from: "1.0.0"),


Or manually checkout the submodule with git submodule add [email protected]:hoangtaiki/Refreshable.git, drag Refreshable.xcodeproj to your project, and add Refreshable as a build dependency.


You can set the value of the placeholder property just like using UITextField.

Interface Builder

  1. Drag a UITextView object onto the canvas.
  2. In the Identity inspector, set the Custom Class name to PlaceholderUITextView.
  3. In the Attributes inspector, you can change the value of the placeholder property directly.


let placeholderTextView = PlaceholderUITextView(frame: view.bounds)
placeholderTextView.placeholder = "What's on your mind?"


To run the example project, clone the repo, and run pod install from the Example directory first.

Some notes

If you run Example project you can see UITextView have some gap from four edges (top, right, bottom, left).
This gap is not a feature of PlaceholderUITextView. It is the default features of UITextView.
They are: textContainerInset and lineFragmentPadding.

Defaut UITextView has textContainerInset = UIEdgeInsets(top: 8, left: 0, bottom: 8, right: 0) and lineFragmentPadding = 5. So that if you run Example Project you can see that: UITextField always be moved a bit by these two default values.
To avoid this happening you have two ways:

  • Set textContainerInset by .zero and lineFragmentPadding by 0
  • Change constraint between UITextView and superview.