A light-weight UITextView subclass that adds support for placeholder.

Overview

RSKPlaceholderTextView Swift 5.1 Swift Package Manager Compatible CocoaPods Compatible Carthage compatible

Sample

A light-weight UITextView subclass that adds support for placeholder.

Installation

Using Swift Package Manager

  1. To add the RSKPlaceholderTextView package to your Xcode project, select File > Swift Packages > Add Package Dependency and enter the repository URL.

     https://github.com/ruslanskorb/RSKPlaceholderTextView.git
    

Using CocoaPods

  1. Add the pod RSKPlaceholderTextView to your Podfile.

    pod 'RSKPlaceholderTextView'
    
  2. Run pod install from Terminal, then open your app's .xcworkspace file to launch Xcode.

Using Carthage

  1. Add the ruslanskorb/RSKPlaceholderTextView project to your Cartfile.

    github "ruslanskorb/RSKPlaceholderTextView"
    
  2. Run carthage update, then follow the additional steps required to add the iOS and/or Mac frameworks into your project.

Basic Usage

Import the module.

import RSKPlaceholderTextView

Just create a text view and set the placeholder.

override func viewDidLoad() {
    super.viewDidLoad()

    self.textView = RSKPlaceholderTextView(frame: CGRect(x: 0, y: 20, width: self.view.frame.width, height: 100))
    self.textView.placeholder = "What do you want to say about this event?"

    self.view.addSubview(self.textView)
}

Demo

Build and run the RSKPlaceholderTextViewExample project in Xcode to see RSKPlaceholderTextView in action. Have fun. Figure out hooks for customization.

Contact

Ruslan Skorb

License

This project is available under the Apache License, version 2.0. See the LICENSE file for more info.

Comments
  • Update for Xcode 10.2 / Swift 5

    Update for Xcode 10.2 / Swift 5

    • bump version to 5.0.0
    • add swift version to podspec
    • remove file .swift-version (deprecated)
    • update project to recommended settings
    • update RSKPlaceholderTextViewExample
    $ pod lib lint
    
     -> RSKPlaceholderTextView (4.0.0)
        - NOTE  | xcodebuild:  note: Using new build system
        - NOTE  | [iOS] xcodebuild:  note: Planning build
        - NOTE  | [iOS] xcodebuild:  note: Constructing build description
    
    RSKPlaceholderTextView passed validation.
    

    NOTES:

    • still needs to be tagged and pushed to cocoapods obviously
    • @unknown default case for UIUserInterfaceLayoutDirection will cause an assertionFailure(_:) (see here)
    opened by weakfl 8
  • Provide example code in Readme

    Provide example code in Readme

    Your lib is great.

    I'd be cool to show some code on how to use RSKPlaceholderTextView instead of me having to open the example app. You can check this link and this link for ideas.

    Let me know how I can help!

    enhancement 
    opened by lfarah 5
  • Using RSKPlaceholderTextView with swift Storyboard

    Using RSKPlaceholderTextView with swift Storyboard

    I added this control in Pods I'm placing UITextView in storyboard and changed the class to "RSKPlaceholderTextView".

    When compiling, its throwing warning that its not able to find the class "RSKPlaceholderTextView" is not found and changing to "UITextView".

    When running the app, its crashing while setting placeholder text.

    user bug 
    opened by satyam90 5
  • Multiline Placeholder Support

    Multiline Placeholder Support

    Issue is Multiline placeholder support is available in example project (version - https://github.com/ruslanskorb/RSKPlaceholderTextView/releases/tag/5.0.1) But when you try with latest version it does not work as expected.

    needs more information 
    opened by shubham14896 4
  • Support for wrapping the placeholder text

    Support for wrapping the placeholder text

    This PR implements support for wrapping the placeholder text on multiple lines.

    As suggested here, in our project we use RSKPlaceholderTextView for use inside a table view, with a bit of our own code to resize cell height as the user types. So far so good, except that the view doesn't display all of the placeholder text when it is longer than can fit on one line.

    This PR adds an override of intrinsicContentSize to return a value calculated from the same metrics used to draw the placeholder text.

    opened by sroymeetup 2
  • textField.returnKeyType = .next  无效

    textField.returnKeyType = .next 无效

    lazy var steward_2Body:RSKPlaceholderTextView = {
        let textField = RSKPlaceholderTextView()
        textField.font = UIFont.systemFont(ofSize: 14)
        textField.layer.borderWidth = 1
        textField.layer.borderColor = UIColor.black.cgColor
        textField.returnKeyType = .next
        return textField
    }()
    

    textField.returnKeyType = .next 这句话无效。。。。。

    invalid 
    opened by PhoenixLeeSin 2
  • Clear text after tap

    Clear text after tap

    Hi and thanks for your work! How to make the placeholder disappear as soon as I place the cursor and the keyboard is shown, and not when I just start typing?

    question 
    opened by fury21 1
  • Support of Swift Package Manager

    Support of Swift Package Manager

    Adds Package.swift file which enables usage with SPM. Note, that the most correct usage with SPM will be possible only when there is new release that includes Package.swift. Until then, dependency can be added by branch or commit hash which is not allowed in published packages.

    opened by TwoDollarsEsq 1
  • Support for building for iOS extension

    Support for building for iOS extension

    Hi, right now this project can't be used in iOS extensions (like a share extension with user inputs) because of a fallback for iOS 8.0.

    If we remove that fallback and build for iOS 9.0 as the base deployment target, this project will work with iOS extensions just fine. I wasn't able to utilize availability conditions because the iOSApplicationExtension condition is a subset of iOS condition.

    If this is something you'd like to add to the project, it'd be great! If not, just reject the pull request and I'll use my fork of your project.

    opened by yood 1
  • you can't specify placeholder color in property `attributedPlaceholder`.

    you can't specify placeholder color in property `attributedPlaceholder`.

    as private method placeholderAttributes not respecting placeholder color in property attributedPlaceholder.

    if you use RSKPlaceholderTextView like this:

    textView.attributedPlaceholder = NSAttributedString(string: "placeholder", attributes: [NSAttributedString.Key.foregroundColor: UIColor.red])
    textView.font = UIFont.systemFont(ofSize: 16)
    

    the placeholder color will be placeholderColor default value instead of red.

    bug 
    opened by jimmychen2014 0
Releases(6.1.0)
Owner
Ruslan Skorb
"The best way to predict the future is to create it" – Abraham Lincoln. Let's create our future together! Founder & Principal Software Engineer @ R.SK Lab
Ruslan Skorb
DGPlaceholderTextView - A light-weight UITextView that supports for placeholder

DGPlaceholderTextView Requirements Installation Usage Properties DGPlaceholderTe

donggyu 5 Jan 26, 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 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
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
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 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
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
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