Skip to content

udbhateja/UDPlaceholderTextView

Repository files navigation

UDPlaceholderTextView

Version License Platform

TUDPlaceholderTextView

Example

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

Demo

UDPlaceholderTextView

Requirements

  • iOS 9.0+
  • Swift 5+

Installation

Cocoapods

UDPlaceholderTextView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'UDPlaceholderTextView'

Swift Package Manager

To install UDPlaceholderTextView package into your packages, add a reference to UDPlaceholderTextView and a targeting release version in the dependencies section in Package.swift file:

import PackageDescription

let package = Package(
   name: "YOUR_PROJECT_NAME",
   products: [],
   dependencies: [
       .package(url: "https://github.com/udbhateja/UDPlaceholderTextView.git", from: "0.1.0")
   ]
)

To install UDPlaceholderTextView package via Xcode

Manually

Drag and drop the file UDPlaceholderTextView.swift into your project folder. Make sure Copy Files is checked and file is added to target.

Usage

In case of Cocoapods

import UDPlaceholderTextView

1. Using Code

var textView: UDPlaceholderTextView!
override func viewDidLoad() {
   super.viewDidLoad()
   // Do any additional setup after loading the view, typically from a nib.
   textView = UDPlaceholderTextView(frame: CGRect(x: 0, y: 0, width: 100.0, height: 100.0))
   textView.placeholder = "Please enter your comments"
   textView.placeholderColor = UIColor.red
}

2. Using Storyboard

Drag a UITextView object in your ViewController. Change the class to UDPlaceholderTextView in Identity Inspector.

Refer screenshot below:

UDPlaceholderTextView

You can change the properties from Storyboard as well.

UDPlaceholderTextView

In your code you can access the text normally like UITextView. All other UITextView properties and methods can be accessed normally.

@IBOutlet weak var textView: UDPlaceholderTextView!
let text = textView.text

Properties

  • placeholder - Placeholder Text

    textView.placeholder = "Please enter your comments"
    
  • placeholderColor - Color of the placeholder text.

    textView.placeholderColor = UIColor.red
    

Contributions

I'd love to see you contributing to this project by proposing or adding features, reporting bugs, or spreading the word. Any help or contribution is appreciated.

Author

udbhateja, udaybhateja@ymail.com

https://bit.ly/udbhateja

License

UDPlaceholderTextView is available under the MIT license. See the LICENSE file for more info.

About

A subclass of UITextView with add-in capabilities for Placeholder.

Resources

License

Stars

Watchers

Forks

Packages

No packages published