UITextView subclass which displays a suffix after editable text and a placeholder.
Objective-C Swift Shell Ruby
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Example Done item too Jan 2, 2016
ZSWSuffixTextView
.gitignore Initial commit Dec 27, 2015
.travis.yml Initial commit Dec 27, 2015
LICENSE
README.md Mention ZSWTaggedString, too Jan 2, 2016
ZSWSuffixTextView.podspec
_Pods.xcodeproj Initial commit Dec 27, 2015

README.md

ZSWSuffixTextView

Version License Platform

ZSWSuffixTextView is a UITextView subclass which supports:

  • Suffix text, appended after the editable area
  • Placeholder text, for when nothing has been entered

You can use either of these independently, or together. This is done without modifying any text so your delegates do not need modification for text processing. It's a drop-in replacement.

You can view the header file for more detailed documentation on configuration, or view the example project for general usage.

Placeholder

You can set placeholder text and text color. Other attributes for the placeholder text are inherited from the text view.

var placeholderTextColor: UIColor! // defaults to 70% black
var placeholder: String?

You may update the placeholder text at any time.

Suffix text

You can set an NSString or NSAttributedString version of the suffix text. By default, the font and color attributes are inherited from the text view.

var suffixTextColor: UIColor! // defaults to same as text
var suffix: String?
var attributedSuffix: NSAttributedString?
var suffixSpacing: CGFloat

If you use an attributed version, be aware that the NSParagraphStyle will be modified (or added) to handle positioning (via firstLineHeadIndent) and forced right-to-left (via baseWritingDirection).

A good way to generate your suffix text, especially when you want sub-string coloring, is to use ZSWTaggedString which allows generating attributed strings easily.

Tappable

With the Tappable subspec, this class uses ZSWTappableLabel. This allows regions of your suffix text to be tappable, similar to the Facebook status updating screen. This is done via two exposed properties:

var suffixTapDelegate: ZSWTappableLabelTapDelegate?
var suffixLongPressDelegate: ZSWTappableLabelLongPressDelegate?

For more information on setting up tappable regions, refer to the documentation for the tappable label.

Right-to-left

ZSWSuffixTextView supports right-to-left text input for the placeholder and the suffix text.

If you provide left-to-right text for either, they are forced to behave like right-to-left.

Installation

ZSWSuffixTextView is available through CocoaPods. To install it, simply add the following line(s) to your Podfile:

pod "ZSWSuffixTextView", "~> 1.0"
pod "ZSWSuffixTextView/Tappable", "~> 1.0" # for tap support

License

ZSWSuffixTextView is available under the MIT license.