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 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.
You can set an
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
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 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.
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.
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
ZSWSuffixTextView is available under the MIT license.