ZSWSuffixTextView 1.0

ZSWSuffixTextView 1.0

TestsTested
LangLanguage Obj-CObjective C
License MIT
ReleasedLast Release Jan 2016

Maintained by Zachary West.



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).

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.