YYText

Powerful text framework for iOS to display and edit rich text.

Subscribe to updates I use YYText


Statistics on YYText

Number of watchers on Github 7102
Number of open issues 322
Average time to close an issue 5 days
Main language Objective-C
Average time to merge a PR about 14 hours
Open pull requests 21+
Closed pull requests 8+
Last commit 12 months ago
Repo Created over 2 years ago
Repo Last Updated 4 months ago
Size 21.3 MB
Organization / Authoribireme
Latest Release1.0.6
Contributors6
Page Updated
Do you use YYText? Leave a review!
View open issues (322)
View YYText activity
View on github
Latest Open Source Launches
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating YYText for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

YYText

License MIT  Carthage compatible  CocoaPods  CocoaPods  Support  Build Status

Powerful text framework for iOS to display and edit rich text.
(It's a component of YYKit)

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

// YYLabel (similar to UILabel)
YYLabel *label = [YYLabel new];
label.frame = ...
label.font = ...
label.textColor = ...
label.textAlignment = ...
label.lineBreakMode = ...
label.numberOfLines = ...
label.text = ...

// YYTextView (similar to UITextView)
YYTextView *textView = [YYTextView new];
textView.frame = ...
textView.font = ...
textView.textColor = ...
textView.dataDetectorTypes = ...
textView.placeHolderText = ...
textView.placeHolderTextColor = ...
textView.delegate = ...

Attributed text

// 1. Create an attributed string.
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"Some Text, blabla..."];

// 2. Set attributes to text, you can use almost all CoreText attributes.
text.yy_font = [UIFont boldSystemFontOfSize:30];
text.yy_color = [UIColor blueColor];
[text yy_setColor:[UIColor redColor] range:NSMakeRange(0, 4)];
text.yy_lineSpacing = 10;

// 3. Set to YYLabel or YYTextView.
YYLabel *label = [YYLabel new];
label.frame = ...
label.attributedString = text;

YYTextView *textView = [YYTextView new];
textView.frame = ...
textView.attributedString = text;

Text highlight

You can use some convenience methods to set text highlight:

[text yy_setTextHighlightRange:range
                       color:[UIColor blueColor]
             backgroundColor:[UIColor grayColor]
                   tapAction:^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect){ 
                       NSLog(@"tap text range:..."); 
                   }];

Or set the text highlight with your custom config:

// 1. Create a 'highlight' attribute for text.
YYTextBorder *border = [YYTextBorder borderWithFillColor:[UIColor grayColor] cornerRadius:3];

YYTextHighlight *highlight = [YYTextHighlight new];
[highlight setColor:[UIColor whiteColor]];
[highlight setBackgroundBorder:highlightBorder];
highlight.tapAction = ^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) {
 NSLog(@"tap text range:..."); 
 // you can also set the action handler to YYLabel or YYTextView.
};

// 2. Add 'highlight' attribute to a range of text.
[attributedText yy_setTextHighlight:highlight range:highlightRange];

// 3. Set text to label or text view.
YYLabel *label = ...
label.attributedText = attributedText

YYTextView *textView = ...
textView.attributedText = ...

// 4. Receive user interactive action.
label.highlightTapAction = ^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) {
   NSLog(@"tap text range:...");
};
label.highlightLongPressAction = ^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) {
   NSLog(@"long press text range:...");
};

@UITextViewDelegate
- (void)textView:(YYTextView *)textView didTapHighlight:(YYTextHighlight *)highlight inRange:(NSRange)characterRange rect:(CGRect)rect {
   NSLog(@"tap text range:...");
}
- (void)textView:(YYTextView *)textView didLongPressHighlight:(YYTextHighlight *)highlight inRange:(NSRange)characterRange rect:(CGRect)rect {
   NSLog(@"long press text range:...");
}

Text attachments

NSMutableAttributedString *text = [NSMutableAttributedString new];
UIFont *font = [UIFont systemFontOfSize:16];
NSMutableAttributedString *attachment = nil;

// UIImage attachment
UIImage *image = [UIImage imageNamed:@"dribbble64_imageio"];
attachment = [NSMutableAttributedString yy_attachmentStringWithContent:image contentMode:UIViewContentModeCenter attachmentSize:image.size alignToFont:font alignment:YYTextVerticalAlignmentCenter];
[text appendAttributedString: attachment];

// UIView attachment
UISwitch *switcher = [UISwitch new];
[switcher sizeToFit];
attachment = [NSMutableAttributedString yy_attachmentStringWithContent:switcher contentMode:UIViewContentModeBottom attachmentSize:switcher.size alignToFont:font alignment:YYTextVerticalAlignmentCenter];
[text appendAttributedString: attachment];

// CALayer attachment
CASharpLayer *layer = [CASharpLayer layer];
layer.path = ...
attachment = [NSMutableAttributedString yy_attachmentStringWithContent:layer contentMode:UIViewContentModeBottom attachmentSize:switcher.size alignToFont:font alignment:YYTextVerticalAlignmentCenter];
[text appendAttributedString: attachment];

Text layout calculation

NSAttributedString *text = ...
CGSize size = CGSizeMake(100, CGFLOAT_MAX);
YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:size text:text];

// get text bounding
layout.textBoundingRect; // get bounding rect
layout.textBoundingSize; // get bounding size

 // query text layout
[layout lineIndexForPoint:CGPointMake(10,10)];
[layout closestLineIndexForPoint:CGPointMake(10,10)];
[layout closestPositionToPoint:CGPointMake(10,10)];
[layout textRangeAtPoint:CGPointMake(10,10)];
[layout rectForRange:[YYTextRange rangeWithRange:NSMakeRange(10,2)]];
[layout selectionRectsForRange:[YYTextRange rangeWithRange:NSMakeRange(10,2)]];

// text layout display
YYLabel *label = [YYLabel new];
label.size = layout.textBoundingSize;
label.textLayout = layout;

Adjust text line position

// Convenience methods:
// 1. Create a text line position modifier, implements `YYTextLinePositionModifier` protocol.
// 2. Set it to label or text view.

YYTextLinePositionSimpleModifier *modifier = [YYTextLinePositionSimpleModifier new];
modifier.fixedLineHeight = 24;

YYLabel *label = [YYLabel new];
label.linePositionModifier = modifier;

// Fully control
YYTextLinePositionSimpleModifier *modifier = [YYTextLinePositionSimpleModifier new];
modifier.fixedLineHeight = 24;

YYTextContainer *container = [YYTextContainer new];
container.size = CGSizeMake(100, CGFLOAT_MAX);
container.linePositionModifier = modifier;

YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:text];
YYLabel *label = [YYLabel new];
label.size = layout.textBoundingSize;
label.textLayout = layout;

Asynchronous layout and rendering

// If you have performance issues,
// you may enable the asynchronous display mode.
YYLabel *label = ...
label.displaysAsynchronously = YES;

// If you want to get the highest performance, you should do 
// text layout with `YYTextLayout` class in background thread.
YYLabel *label = [YYLabel new];
label.displaysAsynchronously = YES;
label.ignoreCommonProperties = YES;

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
   // Create attributed string.
   NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"Some Text"];
   text.yy_font = [UIFont systemFontOfSize:16];
   text.yy_color = [UIColor grayColor];
   [text yy_setColor:[UIColor redColor] range:NSMakeRange(0, 4)];

   // Create text container
   YYTextContainer *container = [YYTextContainer new];
   container.size = CGSizeMake(100, CGFLOAT_MAX);
   container.maximumNumberOfRows = 0;

   // Generate a text layout.
   YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:text];

   dispatch_async(dispatch_get_main_queue(), ^{
       label.size = layout.textBoundingSize;
       label.textLayout = layout;
   });
});

Text container control

YYLabel *label = ...
label.textContainerPath = [UIBezierPath bezierPathWith...];
label.exclusionPaths =  @[[UIBezierPath bezierPathWith...];,...];
label.textContainerInset = UIEdgeInsetsMake(...);
label.verticalForm = YES/NO;

YYTextView *textView = ...
textView.exclusionPaths =   @[[UIBezierPath bezierPathWith...];,...];
textView.textContainerInset = UIEdgeInsetsMake(...);
textView.verticalForm = YES/NO;

Text parser

// 1. Create a text parser

YYTextSimpleEmoticonParser *parser = [YYTextSimpleEmoticonParser new];
NSMutableDictionary *mapper = [NSMutableDictionary new];
mapper[@":smile:"] = [UIImage imageNamed:@"smile.png"];
mapper[@":cool:"] = [UIImage imageNamed:@"cool.png"];
mapper[@":cry:"] = [UIImage imageNamed:@"cry.png"];
mapper[@":wink:"] = [UIImage imageNamed:@"wink.png"];
parser.emoticonMapper = mapper;

YYTextSimpleMarkdownParser *parser = [YYTextSimpleMarkdownParser new];
[parser setColorWithDarkTheme];

MyCustomParser *parser = ... // custom parser

// 2. Attach parser to label or text view
YYLabel *label = ...
label.textParser = parser;

YYTextView *textView = ...
textView.textParser = parser;

Debug

// Set a shared debug option to show text layout result.
YYTextDebugOption *debugOptions = [YYTextDebugOption new];
debugOptions.baselineColor = [UIColor redColor];
debugOptions.CTFrameBorderColor = [UIColor redColor];
debugOptions.CTLineFillColor = [UIColor colorWithRed:0.000 green:0.463 blue:1.000 alpha:0.180];
debugOptions.CGGlyphBorderColor = [UIColor colorWithRed:1.000 green:0.524 blue:0.000 alpha:0.200];
[YYTextDebugOption setSharedDebugOption:debugOptions];

More examples

See Demo/YYTextDemo.xcodeproj for more examples:



Installation

CocoaPods

  1. Add pod 'YYText' to your Podfile.
  2. Run pod install or pod update.
  3. Import <YYText/YYText.h>.

Carthage

  1. Add github "ibireme/YYText" to your Cartfile.
  2. Run carthage update --platform ios and add the framework to your project.
  3. Import <YYText/YYText.h>.

Manually

  1. Download all the files in the YYText subdirectory.
  2. Add the source files to your Xcode project.
  3. Link with required frameworks:
    • UIKit
    • CoreFoundation
    • CoreText
    • QuartzCore
    • Accelerate
    • MobileCoreServices
  4. 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+.

License

YYText is released under the MIT license. See LICENSE file for details.



============== iOS
( YYKit )

==============

- API UILabel UITextView

  • CoreText

- UIImageUIViewCALayer

- ( Markdown/)

-

-

-

  • VoiceOver

- Interface Builder

============== YYText TextKit

==============

YYText

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

YYText CoreText

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)

==============

// YYLabel ( UILabel )
YYLabel *label = [YYLabel new];
label.frame = ...
label.font = ...
label.textColor = ...
label.textAlignment = ...
label.lineBreakMode = ...
label.numberOfLines = ...
label.text = ...

// YYTextView ( UITextView )
YYTextView *textView = [YYTextView new];
textView.frame = ...
textView.font = ...
textView.textColor = ...
textView.dataDetectorTypes = ...
textView.placeHolderText = ...
textView.placeHolderTextColor = ...
textView.delegate = ...
// 1. 
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"Some Text, blabla..."];

// 2. 
text.yy_font = [UIFont boldSystemFontOfSize:30];
text.yy_color = [UIColor blueColor];
[text yy_setColor:[UIColor redColor] range:NSMakeRange(0, 4)];
text.yy_lineSpacing = 10;

// 3.  YYLabel  YYTextView
YYLabel *label = [YYLabel new];
label.frame = ...
label.attributedString = text;

YYTextView *textView = [YYTextView new];
textView.frame = ...
textView.attributedString = text;
[text yy_setTextHighlightRange:range
                       color:[UIColor blueColor]
             backgroundColor:[UIColor grayColor]
                   tapAction:^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect){ 
                       NSLog(@"tap text range:..."); 
                   }];
// 1. """"
YYTextBorder *border = [YYTextBorder borderWithFillColor:[UIColor grayColor] cornerRadius:3];

YYTextHighlight *highlight = [YYTextHighlight new];
[highlight setColor:[UIColor whiteColor]];
[highlight setBackgroundBorder:highlightBorder];
highlight.tapAction = ^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) {
 NSLog(@"tap text range:..."); 
 //  YYLabel  YYTextView 
};

// 2. ""
[attributedText yy_setTextHighlight:highlight range:highlightRange];

// 3.  YYLabel  YYTextView
YYLabel *label = ...
label.attributedText = attributedText

YYTextView *textView = ...
textView.attributedText = ...

// 4. 
label.highlightTapAction = ^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) {
   NSLog(@"tap text range:...");
};
label.highlightLongPressAction = ^(UIView *containerView, NSAttributedString *text, NSRange range, CGRect rect) {
   NSLog(@"long press text range:...");
};

@UITextViewDelegate
- (void)textView:(YYTextView *)textView didTapHighlight:(YYTextHighlight *)highlight inRange:(NSRange)characterRange rect:(CGRect)rect {
   NSLog(@"tap text range:...");
}
- (void)textView:(YYTextView *)textView didLongPressHighlight:(YYTextHighlight *)highlight inRange:(NSRange)characterRange rect:(CGRect)rect {
   NSLog(@"long press text range:...");
}
NSMutableAttributedString *text = [NSMutableAttributedString new];
UIFont *font = [UIFont systemFontOfSize:16];
NSMutableAttributedString *attachment = nil;

//  UIImage
UIImage *image = [UIImage imageNamed:@"dribbble64_imageio"];
attachment = [NSMutableAttributedString yy_attachmentStringWithContent:image contentMode:UIViewContentModeCenter attachmentSize:image.size alignToFont:font alignment:YYTextVerticalAlignmentCenter];
[text appendAttributedString: attachment];

//  UIView
UISwitch *switcher = [UISwitch new];
[switcher sizeToFit];
attachment = [NSMutableAttributedString yy_attachmentStringWithContent:switcher contentMode:UIViewContentModeBottom attachmentSize:switcher.size alignToFont:font alignment:YYTextVerticalAlignmentCenter];
[text appendAttributedString: attachment];

//  CALayer
CASharpLayer *layer = [CASharpLayer layer];
layer.path = ...
attachment = [NSMutableAttributedString yy_attachmentStringWithContent:layer contentMode:UIViewContentModeBottom attachmentSize:switcher.size alignToFont:font alignment:YYTextVerticalAlignmentCenter];
[text appendAttributedString: attachment];
NSAttributedString *text = ...
CGSize size = CGSizeMake(100, CGFLOAT_MAX);
YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:size text:text];

// 
layout.textBoundingRect; // get bounding rect
layout.textBoundingSize; // get bounding size

 // 
[layout lineIndexForPoint:CGPointMake(10,10)];
[layout closestLineIndexForPoint:CGPointMake(10,10)];
[layout closestPositionToPoint:CGPointMake(10,10)];
[layout textRangeAtPoint:CGPointMake(10,10)];
[layout rectForRange:[YYTextRange rangeWithRange:NSMakeRange(10,2)]];
[layout selectionRectsForRange:[YYTextRange rangeWithRange:NSMakeRange(10,2)]];

// 
YYLabel *label = [YYLabel new];
label.size = layout.textBoundingSize;
label.textLayout = layout;
// Emoji 
// 

// :
// 1.  `YYTextLinePositionModifier` 
// 2.  Label  TextView

YYTextLinePositionSimpleModifier *modifier = [YYTextLinePositionSimpleModifier new];
modifier.fixedLineHeight = 24;

YYLabel *label = [YYLabel new];
label.linePositionModifier = modifier;

// :
YYTextLinePositionSimpleModifier *modifier = [YYTextLinePositionSimpleModifier new];
modifier.fixedLineHeight = 24;

YYTextContainer *container = [YYTextContainer new];
container.size = CGSizeMake(100, CGFLOAT_MAX);
container.linePositionModifier = modifier;

YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:text];
YYLabel *label = [YYLabel new];
label.size = layout.textBoundingSize;
label.textLayout = layout;
// 
YYLabel *label = ...
label.displaysAsynchronously = YES;

//  `YYTextLayout`  
YYLabel *label = [YYLabel new];
label.displaysAsynchronously = YES; //
label.ignoreCommonProperties = YES; // textLayout 

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
   // 
   NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"Some Text"];
   text.yy_font = [UIFont systemFontOfSize:16];
   text.yy_color = [UIColor grayColor];
   [text yy_setColor:[UIColor redColor] range:NSMakeRange(0, 4)];

   // 
   YYTextContainer *container = [YYTextContainer new];
   container.size = CGSizeMake(100, CGFLOAT_MAX);
   container.maximumNumberOfRows = 0;

   // 
   YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:text];

   dispatch_async(dispatch_get_main_queue(), ^{
       label.size = layout.textBoundingSize;
       label.textLayout = layout;
   });
});
YYLabel *label = ...
label.textContainerPath = [UIBezierPath bezierPathWith...];
label.exclusionPaths =  @[[UIBezierPath bezierPathWith...];,...];
label.textContainerInset = UIEdgeInsetsMake(...);
label.verticalForm = YES/NO;

YYTextView *textView = ...
textView.exclusionPaths =   @[[UIBezierPath bezierPathWith...];,...];
textView.textContainerInset = UIEdgeInsetsMake(...);
textView.verticalForm = YES/NO;
// 1. 

// 
YYTextSimpleEmoticonParser *parser = [YYTextSimpleEmoticonParser new];
NSMutableDictionary *mapper = [NSMutableDictionary new];
mapper[@":smile:"] = [UIImage imageNamed:@"smile.png"];
mapper[@":cool:"] = [UIImage imageNamed:@"cool.png"];
mapper[@":cry:"] = [UIImage imageNamed:@"cry.png"];
mapper[@":wink:"] = [UIImage imageNamed:@"wink.png"];
parser.emoticonMapper = mapper;

//  markdown 
YYTextSimpleMarkdownParser *parser = [YYTextSimpleMarkdownParser new];
[parser setColorWithDarkTheme];

//  `YYTextParser` 
MyCustomParser *parser = ... 

// 2.  YYLabel  YYTextView
YYLabel *label = ...
label.textParser = parser;

YYTextView *textView = ...
textView.textParser = parser;

Debug

//  debug option 
YYTextDebugOption *debugOptions = [YYTextDebugOption new];
debugOptions.baselineColor = [UIColor redColor];
debugOptions.CTFrameBorderColor = [UIColor redColor];
debugOptions.CTLineFillColor = [UIColor colorWithRed:0.000 green:0.463 blue:1.000 alpha:0.180];
debugOptions.CGGlyphBorderColor = [UIColor colorWithRed:1.000 green:0.524 blue:0.000 alpha:0.200];
[YYTextDebugOption setSharedDebugOption:debugOptions];

Demo/YYTextDemo.xcodeproj:



==============

CocoaPods

  1. Podfile pod 'YYText'
  2. pod install pod update
  3. <YYText/YYText.h>

Carthage

  1. Cartfile github "ibireme/YYText"
  2. carthage update --platform ios framework
  3. <YYText/YYText.h>
  1. YYText
  2. YYText ()
  3. frameworks:
    • UIKit
    • CoreFoundation
    • CoreText
    • QuartzCore
    • Accelerate
    • MobileCoreServices
  4. YYText.h

YYImage YYWebImage (GIF/APNG/WebP)

============== CocoaDocs API appledoc

============== iOS 6.0 Xcode 8.0

==============

  • YYText CoreText/TextKit NSBackgroundColorNSStrikethroughNSUnderlineNSAttachmentNSLink YYText
  • YYTextView
  • exclusionPaths
  • textContainerPath RunDelegate RunDelegate CoreText Bug Feature

============== YYText MIT LICENSE

YYText open issues Ask a question     (View All Issues)
  • over 1 year 竖排输入,改变字体大小,导致YYTextLayout的constraint 越界,导致白屏(测试环境iOS10 it may use larger constraint size when create CTFrame with)
  • over 1 year Question?
  • over 1 year textView先添加文字 然后插入图片 - (BOOL)textView:(YYTextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text这个方法取到的range不正确
  • over 1 year iOS 10 带emoji size 计算错误 附效果图
  • over 1 year YYTextview设置完检查类型为链接,但是怎么获取点击链接的方法事件呢?
  • over 1 year YYLabel 里 Emoji 表情下部被截掉一丢丢
  • over 1 year yytext如何实现文字居中显示,上下居中
  • over 1 year YYTextview如何自动检测链接,并点击跳转
  • over 1 year 你好,YYLabel可以进行复制和粘贴么?可以进行检测链接或者手机号么?
  • over 1 year YYTextView添加图片后输入的文字无样式
  • over 1 year YYText使用第三方键盘,Inline无法使用
  • over 1 year YYLabel 当文本中有空格 或者特殊字符时 使用系统提供的计算方法不会从顶格开始排版 导致frame错误 出现“...现象”boundingRectWithSize:maxSize options:NSStringDrawingUsesLineFragmentOrigin attributes:attrs context:nil
  • over 1 year 在storyboard中一引用就报错,但是能正常运行,有没有解决方案呢?
  • over 1 year 非常感谢你的组件,现在项目中在用YYText,感觉很不错,有个问题想请教一下
  • over 1 year 设置了NSTextAlignmentJustified左右对齐之后 最后一行文字本来被来开 求解!
  • over 1 year 使用系统语音输入时,此时dictation还没有end,把textview的text置空,会出现崩溃
  • over 1 year - (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines;
  • over 1 year 配合HPGrowingTextView使用时,超过设置的行数后会,滚动ScrollView出现放大镜异常划出的问题
  • almost 2 years YYTextView 和UITapGestureRecognizer
  • almost 2 years 如果让最小字体靠上
  • almost 2 years YYTextLayout 可以通用在 UIlabel和YYLabel上来计算高度吗?
  • almost 2 years report a bug
  • almost 2 years two scrollviews: YY wont call textViewShouldBeginEditing until another scrollview stopped scrolling
  • almost 2 years iOS10计算高度还是不对
  • almost 2 years YYText将来会支持html标签吗?
  • almost 2 years YYLabel 在AutoLayout限制下,改变numOfLines没有调整frame大小。
  • almost 2 years iOS10文字竖排大部分情况失效
  • almost 2 years 对一些从右往左的语言(阿拉伯语),layout中的textboundingsize的宽度计算不准确
  • almost 2 years Peek & Pop 操作时UIGraphicsGetCurrentContext() 返回 NULL导致调试台输出错误
  • almost 2 years YYLabel中使用YYTextBorder为什么不能对齐
YYText open pull requests (View All Pulls)
  • set default font, color, shadow and alignment for YYLabel inner attributed string
  • Add issue: cell中有Label,内容为“测试,http://www.google.com”,其中http://www.google.com带链接,点击链接,响应正常,但是点击普通区域,cell点击事件不响应,本次提交处理这种情况;
  • fix becomeFirstResponder delay
  • 添加主动undo和redo方法
  • #434 bug fix
  • Update NSAttributedString+YYText.m
  • 修复 #523 的错误输出
  • fix bug: 长按YYLabel松开之后,会触发textTapAction(单击事件)
  • Add emoticonSize property to YYTextSimpleEmoticonParser
  • 修复 #595 的问题
  • remove warning
  • add textTouchBeganAction
  • add textTouchBeganAction
  • Update YYTextEffectWindow.h
  • Fix Xcode warnings and demo bugs
  • 添加一个属性使事件可以一直传递下去
  • 修复highlightRange长度大于visibleRange长度时出现x/y无限大的情况
  • 修改2个transform的连接顺序,解决font设置matrix,绘制时出现位置不准问题。
  • 调整_updateOuterProperties中设置的顺序
  • fixed typo
  • Fix issue 89 and issue 374
YYText questions on Stackoverflow (View All Questions)
  • What is the meaning of yytext[0]?
  • yytext contains characters not in match
  • What does return yytext[0] do?
  • write parsed tokens and YYTEXT of flex lexical analyser to a file
  • JFlex: How can I let yytext continue during matching
  • Parser - Segmentation fault when calling yytext
  • How to increase yytext size in lex
  • flex atoi(yytext) does not assign value to a variable
  • cant copy the yytext with strcpy
  • yytext matching the end of a regex
  • lex yacc yytext token size
  • Modifying/Filtering yytext before calling yymore()
  • How to copy token found by lex (yytext) to another string?
  • Only part of matched string in flex in yytext
  • Why is the program not returning YYText() or YYLeng()?
  • Parsing yytext for floating point number gives zero
  • Flex Specification yytext
  • Using flex, how can I keep yytext contents when EOF is reached and input is provided via YY_INPUT?
  • yytext equivalent in ocamllex
  • yacc: can't get yytext value from lex to yacc
  • How to pass the yytext from the lex file to yacc?
  • How to convert the (yytext) from small letters to capital letters (in Lex & yacc)?
YYText list of languages used
YYText latest release notes
1.0.6 Bug fixes
  • iOS 7 compatible when set font name with InterfaceBuilder: #404
  • iOS 10 compatible for text layout: #459
  • Fix text border draw defect when the border is out of the view's bounds: #341
  • Fix incorrect state when resize vertical form textview: #483
  • Fix potential crash when get attribute from NSAttributedString with invalid index.
  • Fix Xcode8 warnings
1.0.5 Bug fixes
  • Avoid YYTextEffectWindow become key window
  • Optimize the line truncation token's attributes
  • Fix text render error when use TextGlyphTransformAttribute #284
1.0.4 Bug fixes
  • Add KVO support for property 'textLayout' of YYTextView
  • Fix potential crash in iOS7 #261
  • Fix text rendering problem #229 #262
Other projects in Objective-C