Swiftpack.co - hoangtaiki/PlaceholderUITextView as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by hoangtaiki.
hoangtaiki/PlaceholderUITextView 1.2.0
A missing placeholder for UITextView
⭐️ 15
🕓 5 days ago
.package(url: "https://github.com/hoangtaiki/PlaceholderUITextView.git", from: "1.2.0")


Platform Language CI Status Version License Carthage compatible

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'


Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate PlaceholderUITextView into your Xcode project using Carthage, specify it in your Cartfile:

github "hoangtaiki/PlaceholderUITextView" ~> 1.2

Run carthage update to build the framework and drag the built PlaceholderUITextView.framework into your Xcode project.

Swift Package Manager

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

dependencies: [
    package(url: "https://github.com/sabarics/PlaceholderUITextView.git", .branch("master")),


Or manually checkout the submodule with git submodule add git@github.com:hoangtaiki/PlaceholderUITextView.git, drag PlaceholderUITextView.xcodeproj to your project, and add PlaceholderUITextView 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. UITextView

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.


Hoangtaiki, duchoang.vp@gmail.com


We’re glad you’re interested in Refreshable, and we’d love to see where you take it. If you have suggestions or bug reports, feel free to send pull request or create new issue.

Thanks, and please do take it for a joyride!


Stars: 15
Last commit: 5 days ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

Update Swift 5.0
3 years ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics