YYText
Powerful text framework for iOS to display and edit rich text.
Features
- UILabel and UITextView API compatible
- High performance asynchronous text layout and rendering
- Extended CoreText attributes with more text effects
- Text attachments with UIImage, UIView and CALayer
- Custom highlight text range to allow user interact with
- Text parser support (built in markdown/emoticon parser)
- Text container path and exclusion paths support
- Vertical form layout support (for CJK text)
- Image and attributed text copy/paste support
- Attributed text placeholder support
- Custom keyboard view support
- Undo and redo control
- Attributed text archiver and unarchiver support
- Multi-language and VoiceOver support
- Interface Builder support
- Fully documented
Architecture
YYText vs TextKit

Text Attributes
YYText supported attributes
Demo | Attribute Name | Class |
---|---|---|
![]() |
TextAttachment | YYTextAttachment |
![]() |
TextHighlight | YYTextHighlight |
![]() |
TextBinding | YYTextBinding |
![]() |
TextShadow TextInnerShadow |
YYTextShadow |
![]() |
TextBorder | YYTextBorder |
![]() |
TextBackgroundBorder | YYTextBorder |
![]() |
TextBlockBorder | YYTextBorder |
![]() |
TextGlyphTransform | NSValue(CGAffineTransform) |
![]() |
TextUnderline | YYTextDecoration |
![]() |
TextStrickthrough | YYTextDecoration |
![]() |
TextBackedString | YYTextBackedString |
CoreText attributes which is supported by YYText
Demo | Attribute Name | Class |
---|---|---|
![]() |
Font | UIFont(CTFontRef) |
![]() |
Kern | NSNumber |
![]() |
StrokeWidth | NSNumber |
![]() |
StrokeColor | CGColorRef |
![]() |
Shadow | NSShadow |
![]() |
Ligature | NSNumber |
![]() |
VerticalGlyphForm | NSNumber(BOOL) |
![]() |
WritingDirection | NSArray(NSNumber) |
![]() |
RunDelegate | CTRunDelegateRef |
![]() |
TextAlignment | NSParagraphStyle (NSTextAlignment) |
![]() |
LineBreakMode | NSParagraphStyle (NSLineBreakMode) |
![]() |
LineSpacing | NSParagraphStyle (CGFloat) |
![]() |
ParagraphSpacing ParagraphSpacingBefore |
NSParagraphStyle (CGFloat) |
![]() |
FirstLineHeadIndent | NSParagraphStyle (CGFloat) |
![]() |
HeadIndent | NSParagraphStyle (CGFloat) |
![]() |
TailIndent | NSParagraphStyle (CGFloat) |
![]() |
MinimumLineHeight | NSParagraphStyle (CGFloat) |
![]() |
MaximumLineHeight | NSParagraphStyle (CGFloat) |
![]() |
LineHeightMultiple | NSParagraphStyle (CGFloat) |
![]() |
BaseWritingDirection | NSParagraphStyle (NSWritingDirection) |
![]() |
DefaultTabInterval TabStops |
NSParagraphStyle CGFloat/NSArray(NSTextTab) |
Usage
Basic
Attributed text
Text highlight
You can use some convenience methods to set text highlight:
Or set the text highlight with your custom config:
Text attachments
Text layout calculation
Adjust text line position
Asynchronous layout and rendering
Text container control
Text parser
Debug
More examples
See Demo/YYTextDemo.xcodeproj
for more examples:




Installation
CocoaPods
- Add
pod 'YYText'
to your Podfile. - Run
pod install
orpod update
. - Import <YYText/YYText.h>.
Carthage
- Add
github "ibireme/YYText"
to your Cartfile. - Run
carthage update --platform ios
and add the framework to your project. - Import <YYText/YYText.h>.
Manually
- Download all the files in the
YYText
subdirectory. - Add the source files to your Xcode project.
- Link with required frameworks:
- UIKit
- CoreFoundation
- CoreText
- QuartzCore
- Accelerate
- MobileCoreServices
- Import
YYText.h
.
Notice
You may add YYImage or YYWebImage to your project if you want to support animated image (GIF/APNG/WebP).
Documentation
Full API documentation is available on CocoaDocs.
You can also install documentation locally using appledoc.
Requirements
This library requires iOS 6.0+
and Xcode 8.0+
.