PTPPlaceholderTextView 0.7.3

PTPPlaceholderTextView 0.7.3

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Apr 2019
SPMSupports SPM

Maintained by Pitiphong Phongpattranont.



PTPPlaceholderTextView

A simple naive implementation of UITextView subclass to support placeholder text rendering in UITextView. This PTPPlaceholderTextView comes with IBDesignable, IBInspectable and also UIAppearance support.

Requirements

  • iOS 8+
  • Swift 3.0+

This requirement is due to the Swift runtime is available on iOS 8 or later. If you want to use this PTPPlaceholderTextView, please feel free to contact me. I also have the Objective-C implementation.

Installation

Manaully

This project comes with built in PTPPlaceholderTextView framework target. You can drag PTPPlaceholderTextView.xcproj file into your project, add PTPPlaceholderTextView framework target as a target dependency and link/embed that framework. and Voila!!!

import PTPPlaceholderTextView

Or you can just add PTPPlaceholderTextView.swift into your project.

CocoaPod

Add the following to your Podfile

pod 'PTPPlaceholderTextView'
use_frameworks!

Swift 2.2

You can use PTPPlaceholderTextView in Swift 2.2 by checking out tag 0.6.1

Swift 3.0

You can use PTPPlaceholderTextView in Swift 2.2 by checking out tag 0.7.0

Swift 4.0

You can use PTPPlaceholderTextView in Swift 4.0 by checking out tag 0.7.1

Swift 4.2

You can use PTPPlaceholderTextView in Swift 4.0 by checking out tag 0.7.2

Usage

You can set the placholder text via a placeholder property

textview.placeholder = "Placeholder titile"

Placeholder text color via a placeholderColor property

textview.placeholderColor = UIColor.redColor()

Also you can use an UIAppearance proxy to set the default placeholder text color

PTPPlaceholderTextView.appearance().placeholderColor = UIColor.redColor()

or

PTPPlaceholderTextView.appearanceWhenContainedInInstancesOfClasses([ViewController.self]).placeholderColor = UIColor.redColor()

And because PTPPlaceholderTextView comes with IBDesignable and IBInspectable support. PTPPlaceholderTextView objects also render its preview in your storyboard

Demo App

PTPPlaceholderTextView project comes with a demo app target. You can see PTPPlaceholderTextView in action by just running this demo app target. The demo app comes with Main.storyboard which also demostate the IBDesignable functionality of PTPPlaceholderTextView

Contact

Pitiphong Phongpattranont

License

PTPPlaceholderTextView is released under an MIT License.
Copyright © 2015-present Pitiphong Phongpattranont.