A UITextView subclass that adds support for multiline placeholder written in Swift.

Overview

KMPlaceholderTextView

A UITextView subclass that adds support for multiline placeholder written in Swift.

PlaceholderTextView

Usage

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

Interface Builder

Storyboard

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

Code

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

Installation

CocoaPods

You can install the latest release version of CocoaPods with the following command:

$ gem install cocoapods

Simply add the following line to your Podfile:

platform :ios, '8.0' 
use_frameworks!

target '<Your Target Name>' do
  pod 'KMPlaceholderTextView', '~> 1.4.0'
end

Then, run the following command:

$ pod install

If you are encountering the following warning when using Xcode 8, please make sure to set the Module in the identity inspector of your KMPlaceholderTextView in the interface builder to KMPlaceholderTextView as well:

warning: IB Designables: Using class UITextView for object with custom class because the class KMPlaceholderTextView does not exist

Carthage

Carthage is a decentralized dependency manager that automates the process of adding frameworks to your Cocoa application.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

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

github "MoZhouqi/KMPlaceholderTextView" >= 1.4

Requirements

  • iOS 7.0+
  • Xcode 10

License

KMPlaceholderTextView is released under the MIT license. See LICENSE for details.

Comments
  • Fixes AutoLayout

    Fixes AutoLayout

    If the priority of the width constraint isn't reduced it is automatically broken. Running this without the priority lowered generates a string of warnings in the console log, meaning that this is being over constrained.

    opened by k3zi 10
  • Layout fix: labels doesn't need constraints on booth sides.

    Layout fix: labels doesn't need constraints on booth sides.

    Labels requires only one horizontal and one vertical constraint. Try replace textview's bottom constraint with height constraint, and IB will generate warning. Removing tail and bottom constraints will fix that.

    opened by RealBonus 4
  • Rendering Performance

    Rendering Performance

    Hi The KMPlaceholderTextView won't give access to the UILabel used, so it's really difficult to setup the backgroundColor. Why do we care about it if it's transparent?. One of the slowest operations is rendering. In my case I'm using a lot of instances of KMPlaceholderTextView so if you use “Color Blended Layers" in the iPhone Simulator, you will see a lot of red areas.

    It would be really useful to have access to the background color of the UILabel - through a method- or the UILabel. Right now it's marked as private.

    opened by nicarq 3
  • Feature request: Separate fonts of placeholder and text?

    Feature request: Separate fonts of placeholder and text?

    Other than color, it's very common to have a bolded or italic font for the placeholder, which is different from the regular text the user input. Can you add an option to set the placeholder font? thanks!

    opened by karadis 3
  • IB Designables Failure

    IB Designables Failure

    Hello!

    I'm getting this issue with the latest version...

    file:///Users/sulkuatam/src/app/app-ios/Base.lproj/Main.storyboard: error: IB Designables: Failed to update auto layout status: The bundle “$(PRODUCT_NAME)” couldn’t be loaded because its executable couldn’t be located.

    Not sure what the issue is... thanks in advance for any help!

    screen shot 2016-05-31 at 11 36 52 am
    opened by sinanku 3
  • IB Designables error

    IB Designables error

    error: IB Designables: Failed to render instance of KMPlaceholderTextView: Rendering the view took longer than 200 ms. Your drawing code may suffer from slow performance.

    how can i figure that error?

    opened by misuqian 3
  • Compiling has a error.

    Compiling has a error.

    I use the text view in storyboard named "Mine".And I have the other storyboard. It is normal if I didn't click the Mine storyboard. It will show a Error when I clicked Mine storyboard. It is bad. Error info: Failed to render and update auto layout status for SuggestionViewController (EBX-d9-iDK): dlopen(KMPlaceholderTextView.framework, 1): no suitable image found. Did find: KMPlaceholderTextView.framework: required code signature missing for 'KMPlaceholderTextView.framework'

    opened by XiaoJianXiaoXu 2
  • Can't see placeholder after set in Storyboard

    Can't see placeholder after set in Storyboard

    Hi,

    I have add UITextView and set to KMPlaceholderTextView and set the placeholder property but whenever I run the app placeholder value can't see and getting the below warning.

    Can you please help me asap?

    Unknown class KMPlaceholderTextView in Interface Builder file. Failed to set (placeholder) user defined inspected property on (UITextView): [<UITextView 0x799c5000> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key placeholder. ] Failed to set (placeholder) user defined inspected property on (UITextView): [<UITextView 0x79a17800> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key placeholder.

    opened by Nik20112 2
  • Has ambiguous scrollable content height

    Has ambiguous scrollable content height

    Thank you for useful pod!

    We have an issue using it in a storyboard. When adding a height constraint to the it Storyboard shows the warning: Has ambiguous scrollable content height.

    Is there a workaround for that? Or way to fix it?

    After investigation and StackOverflow research we think it's because IBDesignable KMPlaceholderTextView has placeholder subview, which UITextView UIScrollView probably takes as content and cause ambiguity.

    opened by paulz 2
  • No such module KMPlaceholderTextView

    No such module KMPlaceholderTextView

    We use your library as pod, but pulling from master branch, since pod spec was last updated 2 years ago. Recently we started getting this error. It seems that it is a result of moving source files to Sources folder. Podspec file was not change to accommodate this change.

    opened by OneSman7 1
  • clang: error: no such file or directory: 'KMPlaceholderTextView'

    clang: error: no such file or directory: 'KMPlaceholderTextView'

    I tried to deintegrate Pod and install it again also clean derived data and clean project but no way get the same error in Xcode 10.3

    clang: error: no such file or directory: 'KMPlaceholderTextView' Command Ld failed with a nonzero exit code

    opened by MoElnaggar14 1
  • Update label constraints when textContainer.lineFragmentPadding changes

    Update label constraints when textContainer.lineFragmentPadding changes

    I noticed that the constraints were only updated after updating the textContainer, not after updating textContainer.lineFragmentPadding and decided to make a fix for it.

    opened by markterluun 0
  • YOUTUBE VIDEO TUTORIAL

    YOUTUBE VIDEO TUTORIAL

    Hi, I like KMPlaceholderTextView so much that (besides using it in my own projects) I have created a video tutorial on how to use it:

    https://youtu.be/b-ODoxT7qMo

    If you like it feel free to add it to the README of your repo. You can also add this image so visitors may click on it easily: placeholder in uitextview in swift 2019 thubmnail

    opened by rebeloper 0
Owner
Zhouqi Mo
Zhouqi Mo
An UITextView in Swift. Support auto growing, placeholder and length limit.

GrowingTextView Requirements iOS 8.0 or above Installation CocoaPods GrowingTextView is available through CocoaPods. To install it, simply add the fol

Kenneth Tsang 941 Jan 5, 2023
DGPlaceholderTextView - A light-weight UITextView that supports for placeholder

DGPlaceholderTextView Requirements Installation Usage Properties DGPlaceholderTe

donggyu 5 Jan 26, 2022
ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time

ARAutocompleteTextView is a subclass of UITextView that automatically displays text suggestions in real-time. This is perfect for automatically suggesting the domain as a user types an email address, #hashtag or @alexruperez.

Alex Rupérez 261 Jun 29, 2022
A light-weight UITextView subclass that automatically grows and shrinks.

RSKGrowingTextView A light-weight UITextView subclass that automatically grows and shrinks based on the size of user input and can be constrained by m

Ruslan Skorb 939 Dec 21, 2022
An auto-layout base UITextView subclass which automatically grows with user input and can be constrained by maximal and minimal height - all without a single line of code

Deprecated This library is no longer maintained and is deprecated. The repository might be removed at any point in the future. MBAutoGrowingTextView A

Matej Balantič 125 Jan 13, 2022
DTTextField is a custom textfield with floating placeholder and error label

DTTextField Introduction DTTextField is a UITextField library with floating placeholder and error label. Floating placeholder inspired from JVFloatLab

Dhaval Thanki 310 Jan 5, 2023
HTYTextField A UITextField with bouncy placeholder.

HTYTextField - A UITextField with bouncy placeholder. Screenshot Installation CocoaPods Add the dependency to your Podfile

Hanton Yang 312 Nov 13, 2022
A SwiftUI TextField with a prompt (or placeholder) that floats above the text field when active or not empty. Requires iOS 15.

FloatingPromptTextField A prompt is the label in a text field that informs the user about the kind of content the text field expects. In a default Tex

Emilio Peláez 43 Nov 3, 2022
Simple placeholder move textfield

PlaceholderTextField Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements iOS 11.0 o

null 6 Mar 9, 2022
Placeholder views based on content, loading, error or empty states

StatefulViewController A protocol to enable UIViewControllers or UIViews to present placeholder views based on content, loading, error or empty states

Alexander Schuch 2.1k Dec 8, 2022
TTextField is developed to help developers can initiate a fully standard textfield including title, placeholder and error message in fast and convinient way without having to write many lines of codes

TTextField is developed to help developers can initiate a fully standard textfield including title, placeholder and error message in fast and convinient way without having to write many lines of codes

Nguyen Duc Thinh 7 Aug 28, 2022
This project will add a done button on your UITextField and UITextView

This project will add a done button on your UITextField and UITextView

Botla Venkatesh 0 Nov 23, 2021
UITextField and UITextView subclasses with placeholders that change into floating labels when the fields are populated with text.

Deprecated Please use JVFloatLabeledTextField instead or feel free to chime in on an issue if you'd like to take over the repo. RPFloatingPlaceholders

rob phillips 1.1k Jan 5, 2023
Animated UITextField and UITextView replacement for iOS

AnimatedTextInput iOS custom text input component used in the Jobandtalent app. Installation Use cocoapods to install this custom control in your proj

jobandtalent 757 Dec 15, 2022
UITextField extension in Swift that adds shake animation

UITextField-Shake-Swift UITextField extension in Swift that adds shake animation Initially created by Andrea Mazzini (using Objective-C) on 08/02/14:

null 15 Jul 20, 2021
UITextField category that adds shake animation

UITextField category that adds a shake animation like the password field of the OsX login screen. Screenshot Setup with CocoaPods pod 'UITextField+Sha

Andrea Mazzini 749 Dec 13, 2022
An UITextField subclass to simplify country code's picking. Swift 5.0

Preview Installation NKVPhonePicker is available through CocoaPods. To install it, simply add the following line to your Podfile: pod 'NKVPhonePicker'

Nike Kov 140 Nov 23, 2022
Animated Subclass of UITextField created with CABasicAnimation and CAShapeLayer

JDAnimatedTextField JDAnimatedTextField is animateable UITextField that can significantly enhance your user's experiences and set your app apart from

Jawad Ali 25 Dec 13, 2022
UITextField subclass with floating labels

JVFloatLabeledTextField JVFloatLabeledTextField is the first implementation of a UX pattern that has come to be known the "Float Label Pattern". Due t

Jared Verdi 7.2k Jan 2, 2023