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

Related tags

Text YYText
Overview

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 的属性以支持更多文字效果
  • 支持 UIImage、UIView、CALayer 作为图文混排元素
  • 支持添加自定义样式的、可点击的文本高亮范围
  • 支持自定义文本解析 (内置简单的 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 installpod 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

注意

你可以添加 YYImageYYWebImage 到你的工程,以支持动画格式(GIF/APNG/WebP)的图片。

文档

你可以在 CocoaDocs 查看在线 API 文档,也可以用 appledoc 本地生成文档。

系统要求

该项目最低支持 iOS 6.0Xcode 8.0

已知问题

  • YYText 并不能支持所有 CoreText/TextKit 的属性,比如 NSBackgroundColor、NSStrikethrough、NSUnderline、NSAttachment、NSLink 等,但 YYText 中基本都有对应属性作为替代。详情见上方表格。
  • YYTextView 未实现局部刷新,所以在输入和编辑大量的文本(比如超过大概五千个汉字、或大概一万个英文字符)时会出现较明显的卡顿现象。
  • 竖排版时,添加 exclusionPaths 在少数情况下可能会导致文本显示空白。
  • 当添加了非矩形的 textContainerPath,并且有嵌入大于文本排版方向宽度的 RunDelegate 时,RunDelegate 之后的文字会无法显示。这是 CoreText 的 Bug(或者说是 Feature)。

许可证

YYText 使用 MIT 许可证,详情见 LICENSE 文件。

Comments
  • 根据内容改变容器size 单行时会跳动, 并且回车换行没有计算到高度里。

    根据内容改变容器size 单行时会跳动, 并且回车换行没有计算到高度里。

    • (void)textViewDidChange:(YYTextView *)textView {

      NSAttributedString *text = textView.attributedText; if ([textView.text isEqualToString:@""]) { text = textView.placeholderAttributedText; }

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

      CGSize newSize = CGSizeMake(layout.textBoundingSize.width, layout.textBoundingSize.height);

      NSLog(@"layout.textBoundingSize :%@",NSStringFromCGSize(layout.textBoundingSize)); NSLog(@"self.textView.contentSize :%@",NSStringFromCGSize(self.textView.contentSize));

      self.textView.size = newSize; self.textView.contentSize = newSize;

    }

    log: 2015-11-26 17:48:49.218 testTextView[8110:1979479] layout.textBoundingSize :{249, 23} 2015-11-26 17:48:49.218 testTextView[8110:1979479] self.textView.contentSize :{240, 50}

    enhancement discussion 
    opened by hydyy 33
  • 很严重的crash Bug  ,YYTextview使用attributedText赋值单个系统❤️ 表情,内存会暴增导致crash

    很严重的crash Bug ,YYTextview使用attributedText赋值单个系统❤️ 表情,内存会暴增导致crash

    赋值

    NSDictionary *dic = @{NSFontAttributeName:[UIFont systemFontOfSize:16], NSForegroundColorAttributeName:[UIColor redColor]}; NSMutableAttributedString *mutableAttStr = [[NSMutableAttributedString alloc] initWithString:@"❤️"]; [mutableAttStr addAttributes:dic range:NSMakeRange(0, mutableAttStr.length)];

    YYTextView *textView = [YYTextView new]; textView.selectable = NO; textView.editable = NO; textView.highlightable = YES; textView.scrollEnabled = NO; textView.textContainerInset = UIEdgeInsetsMake(6, 0, 10, 0); textView.dataDetectorTypes = UIDataDetectorTypePhoneNumber | UIDataDetectorTypeLink; YYTextLinePositionSimpleModifier *modifier = [YYTextLinePositionSimpleModifier new]; modifier.fixedLineHeight = 20; textView.linePositionModifier = modifier; textView.attributedText = mutableAttStr; textView.size = self.view.size; textView.delegate = self; if (kiOS7Later) { textView.keyboardDismissMode = UIScrollViewKeyboardDismissModeInteractive; } else { textView.height -= 64; } textView.contentInset = UIEdgeInsetsMake(toolbar.bottom, 0, 0, 0); // textView.scrollIndicatorInsets = textView.contentInset; // textView.selectedRange = NSMakeRange(text.length, 0); [self.view insertSubview:textView belowSubview:toolbar]; self.textView = textView;

    在你的demo里面的YYEditExample.m 里面测试,模拟器内存暴增至16g后崩溃

    opened by CtrlJone 19
  • 行距问题疑问

    行距问题疑问

    YYText 非常棒,我已经扔掉了 TTTAttributedLabel :D 有个疑问,在文字段落时,行距有时候并没有保持一致,原因不明,见截图: img_7582

    这是一段很均匀的纯文本(无 emoji 和 Attachment,也没有任何 highlight 和 binding) 仔细看一下会发现,倒数第六行的行距和其他行不同(「。第二,科创版推出...」这一行)

    具体原因不明,代码片段:

    - (YYLabel *)textLabel
    {
       if (!textLabel) {
           self.textLabel = [[YYLabel alloc] initWithFrame:CGRectZero];
           self.textLabel.userInteractionEnabled = YES;
           self.textLabel.font = [UIFont systemFontOfSize:kEspressoDescriptionTextFontSize];
           self.textLabel.textColor = [UIColor darkGrayColor];
           self.textLabel.lineBreakMode = NSLineBreakByCharWrapping;
           self.textLabel.textVerticalAlignment = YYTextVerticalAlignmentCenter;
           self.textLabel.numberOfLines = 0;
           self.textLabel.displaysAsynchronously = YES;
           [bubbleView addSubview:self.textLabel];
        }
        return textLabel;
    }
    
    - (YYTextLayout *)textLayoutForMessageContent:(NSString *)content font:(UIFont *)font textWidth:(CGFloat)maxWidth {
        NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:content];
        text.yy_font = font;
        text.yy_color = [UIColor darkGrayColor];
        text.yy_lineSpacing = kTextLineSpacing;
        text.yy_lineBreakMode = NSLineBreakByCharWrapping;
    
        // 解析超链接
        [text enumerateTextParser:AKCTextMessageCheckingTypeURL];
    
        // 解析电话号码
        [text enumerateTextParser:AKCTextMessageCheckingTypePhoneNum];
    
        // 解析邮箱地址
        [text enumerateTextParser:AKCTextMessageCheckingTypeEmail];
    
        // 解析表情
        [text enumerateTextParser:AKCTextMessageCheckingTypeFace];
    
        YYTextContainer *container = [YYTextContainer new];
        container.size = CGSizeMake(maxWidth, CGFLOAT_MAX);
    
        YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:text];
    
        return layout;
    }
    
        YYTextLayout *layout = [self textLayoutForMessageContent:msgModel.message_content font:[UIFont systemFontOfSize:16.f] textWidth:maxTextWidth];
    
        width = layout.textBoundingSize.width;
        height = layout.textBoundingSize.height;
    
        self.textLabel.frame = CGRectMake(kLeftBubbleTextLeftInset,
                                                kBubbleTextTopInset,
                                                width,
                                                height);
        self.textLabel.textLayout = layout;
    
    discussion 
    opened by allenforrest 18
  • Swift: include of non-modular header inside framework module

    Swift: include of non-modular header inside framework module"YYText.YYText"

    在使用CocoaPods 加载 YYText 报这个错 include of non-modular header inside framework module"YYText.YYText",截图如下 image

    工程是 Swift ,Bridging-Header.h 是这么引入的

    #import <YYImage/YYImage.h>
    #import <YYText/YYText.h>
    

    podfile:

    platform:ios,'8.0'
    use_frameworks!
    # ignore all warnings from all pods
    inhibit_all_warnings!
    
    target 'demo' do
        pod 'YYImage'
        pod 'YYText'
    end
    

    我还引入了一些其他的库,不知道是不是冲突问题。这是 CocoaPods 的问题么?

    opened by hilen 16
  • swift 中使用pod方式引用不到YYImage

    swift 中使用pod方式引用不到YYImage

    具体报错如下

    Undefined symbols for architecture x86_64:
      "_OBJC_CLASS_$_YYAnimatedImageView", referenced from:
          objc-class-ref in NSAttributedString+YYText.o
          objc-class-ref in YYTextView.o
      "_OBJC_CLASS_$_YYImage", referenced from:
          objc-class-ref in UIPasteboard+YYText.o
          objc-class-ref in YYTextView.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    
    bug 
    opened by seedotlee 14
  • 你好,使用YYTextLayout算高度出问题了

    你好,使用YYTextLayout算高度出问题了

    这是我算高的代码:

    • (CGFloat)calculateAttributeStringHeightWithAttributeString:(NSMutableAttributedString *)string fixWidth:(CGFloat)width { CGSize size = CGSizeMake(width, CGFLOAT_MAX); YYTextLayout *layout = [YYTextLayout layoutWithContainerSize:size text:string]; CGFloat stringHeight = layout.textBoundingSize.height; return stringHeight; }

    这是我Label的设置:

    • (YYLabel *)improveResultLabel { if (!_improveResultLabel) { _improveResultLabel = [YYLabel new]; _improveResultLabel.textAlignment = NSTextAlignmentLeft; _improveResultLabel.font = [UIFont systemFontOfSize:16]; _improveResultLabel.textColor = [HBTThemeManager appCustomGrayFontColor]; _improveResultLabel.lineBreakMode = NSLineBreakByWordWrapping; _improveResultLabel.numberOfLines = 0; } return _improveResultLabel; }

    这是我算高的部分: NSMutableAttributedString _improveAttributeText = [NSMutableAttributedString makeAttributeStringWithText:item.resultEval font:[UIFont systemFontOfSize:fontSize] color:[HBTThemeManager appCustomGrayFontColor]]; improveAttributeText.yy_lineSpacing = lineSpacing; improveAttributeText.yy_maximumLineHeight = fontSize; improveAttributeText.yy_minimumLineHeight = fontSize; CGFloat improveHeight = [NSMutableAttributedString calculateAttributeStringHeightWithAttributeString:stateAttributeText fixWidth:(SCREEN_WIDTH * 0.75 - 2_kViewLeadingAndTrailingOffset)]; 0671f109-4332-4636-9502-9baf518bf58c

    现在计算的文字高度总是缺少一段,给定的宽度限制应该没问题

    opened by hackjie 13
  • YYLabel 在TableViewCell 中 没有刷新

    YYLabel 在TableViewCell 中 没有刷新

    我的初始化代码:

    NSInteger fontsize = 14;
        _titleMessageLabel = [YYLabel new];
        _titleMessageLabel.size = CGSizeMake(180, 21);
        _titleMessageLabel.font = [UIFont systemFontOfSize:fontsize];
        _titleMessageLabel.textColor = [themeMgr colorForKey:@"LabelTextColor2"];
        _titleMessageLabel.lineBreakMode = NSLineBreakByTruncatingTail;
        _titleMessageLabel.numberOfLines = 1;
        _titleMessageLabel.displaysAsynchronously = YES;
        _titleMessageLabel.ignoreCommonProperties = YES;
        _titleMessageLabel.fadeOnAsynchronouslyDisplay = NO;
        _titleMessageLabel.fadeOnHighlight = NO;
        _titleMessageLabel.textVerticalAlignment = YYTextVerticalAlignmentTop;
        _titleMessageLabel.textParser = [FMEmojiParse new]; //解析表情
        [self.contentView addSubview:_titleMessageLabel];
    

    然后在 cellForRowAtIndexPath 方法里面设置Model

    self.nameLabel.text = messageItem.ShowNickName;
        self.titleMessageLabel.text = messageItem.MessageBody;
        NSLog(@"nickName:%@ titleMessageLabel.text:%@ messageBody:%@",messageItem.ShowNickName,self.titleMessageLabel.text, messageItem.MessageBody);
    

    上面我特意打印了log,输出的self.titleMessageLabel.text跟显示的不一样,不知道是不是YYLabel没有刷新。

    下面附上效果图和打印日志: 效果图

    打印日志如下: 日志

    bug 
    opened by lexiaoyao20 13
  • iOS12上有崩溃

    iOS12上有崩溃

    0 CoreGraphics | CGColorSpaceEqualToColorSpaceIgnoringRange + 28 -- | -- 1 QuartzCore | _CARequiresColorMatching + 256 2 QuartzCore | CACGContextEvaluator::update_with_color_components(CGColorSpace*, double const*) + 120 3 QuartzCore | draw_glyphs(CGContextDelegate*, CGRenderingState*, CGGState*, CGAffineTransform const*, unsigned short const*, CGPoint const*, unsigned long) + 184 4 CoreGraphics | _draw_glyphs + 604 5 CoreText | DrawGlyphsAtPositions(TFont const*, unsigned short const*, CGPoint const*, unsigned long, CGContext*, CGAffineTransform, CGAffineTransform, bool) + 2940 6 CoreText | CTFontDrawGlyphsAtPositions + 192 7 CoreText | TRun::DrawGlyphsAtPositions(CGContext*, CFRange, CGPoint const*, bool) const + 228 8 CoreText | CTRunDraw + 176 9 PengPeng | YYTextDrawRun (YYTextLayout.m:2233) 10 PengPeng | -[YYTextLayout drawInContext:size:point:view:layer:debug:cancel:] (YYTextLayout.m:3358 [Inline: YYTextDrawText]) 11 PengPeng | __30-[YYLabel newAsyncDisplayTask]_block_invoke.330 (YYLabel.m:1135) 12 PengPeng | -[YYTextAsyncLayer _displayAsync:] (YYTextAsyncLayer.m:222) 13 PengPeng | -[YYTextAsyncLayer display] (YYTextAsyncLayer.m:115) 14 QuartzCore | CA::Context::commit_transaction(CA::Transaction*) + 548 15 QuartzCore | CA::Transaction::commit() + 608 16 QuartzCore | CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 92 17 CoreFoundation | _CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 32 18 CoreFoundation | ___CFRunLoopDoObservers + 412 19 CoreFoundation | ___CFRunLoopRun + 1264 20 CoreFoundation | CFRunLoopRunSpecific + 436 21 GraphicsServices | GSEventRunModal + 100 22 UIKitCore | UIApplicationMain + 212 23 PengPeng | main (main.m:25) 24 libdyld.dylib | _start + 4

    opened by YasinTian 12
  • 关于 文字超出label范围的省略号(...)的问题

    关于 文字超出label范围的省略号(...)的问题

    如下代码, 设置了最多显示4行, 最后一行尾部没有省略号, 不知道这个怎么设置会显示出来 ` NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:model.content]; attString.yy_font = [UIFont systemFontOfSize:13]; attString.yy_lineSpacing = 10;

    CGSize size = CGSizeMake(SCREEN_WIDTH-2*11-2*20, CGFLOAT_MAX);
    YYTextContainer *container = [YYTextContainer containerWithSize:size];
    container.maximumNumberOfRows = 4;
    YYTextLayout *layout = [YYTextLayout layoutWithContainer:container text:attString];
    CGFloat layoutHeight = layout.textBoundingSize.height;
    
    self.contentLabel.attributedText = attString;
    self.contentLabel.textLayout = layout;
    
    [self.bgImgView addSubview:self.contentLabel];
    [self.contentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.starView.mas_bottom).offset(20);
        make.left.equalTo(self.iconImgView);
        make.right.equalTo(self.bgImgView).offset(-20);
        make.height.mas_equalTo(layoutHeight);
    }];`
    
    opened by CoderLXWang 12
  • 当设置 YYLabel 属性 ignoreCommonProperties = true 时,无法使用 textParser 属性

    当设置 YYLabel 属性 ignoreCommonProperties = true 时,无法使用 textParser 属性

    我开启了 YYLabel 的 ignoreCommonProperties 属性,结果就是把 textParser 属性也忽略了,无法解析表情,另外也没在唯一可用的 textLayout 属性里找到有关设置 textParser 的地方,所以请问作者在开启了 ignoreCommonProperties 的情况下怎么使用解析?另一个看了源码才解惑的地方也说一下,就是 textParser 属性必须放在 text/attributeText 或者 textLayout 属性之后才有效,希望在 README 中顺带提醒一下。谢谢。

    discussion 
    opened by KittenYang 12
  • YYTextBorder   insets属性中的top、bottom 值小于0时,边框绘制不出来~

    YYTextBorder insets属性中的top、bottom 值小于0时,边框绘制不出来~

    YYTextBorder insets属性中的top、bottom 值小于0时,边框绘制不出来~

    代码: NSMutableAttributedString *text = [[NSMutableAttributedString alloc] init]; { NSMutableAttributedString *one = [[NSMutableAttributedString alloc] initWithString:@"文本二"]; one.yy_font = [UIFont boldSystemFontOfSize:10]; one.yy_color = [UIColor redColor]; YYTextBorder *border = [YYTextBorder new]; border.cornerRadius = 50; border.insets = UIEdgeInsetsMake(-4, -10, -4, -10); border.strokeWidth = 0.5; border.strokeColor = one.yy_color; border.lineStyle = YYTextLineStyleSingle; one.yy_textBackgroundBorder = border; [text appendAttributedString:one]; [text appendAttributedString:[self padding]]; } _refLab.attributedText = text;

    image

    bug 
    opened by yunhaiwu 11
  • 大神 UIAlertController 使用失效了 是怎么回事呢

    大神 UIAlertController 使用失效了 是怎么回事呢

    [messageAttribute yy_setTextHighlightRange:[msg rangeOfString:redMsg] color:[UIColor colorConvertFromString:@"#999999"] backgroundColor:[UIColor clearColor] tapAction:^(UIView * _Nonnull containerView, NSAttributedString * _Nonnull text, NSRange range, CGRect rect) { [weakSelf sendOrderGuide]; }]; UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleAlert]; [alert setValue:messageAttribute forKey:@"attributedMessage"];

    创建一个 UIAlertController 使用 attributedMessage 给 UIAlertController 设置msg 点击事件无响应

    opened by SirSai 0
  • _YYTextKeyboardViewFrameObserver崩溃

    _YYTextKeyboardViewFrameObserver崩溃

    __unsafe_unretained UIView *_keyboardView;
    

    推测:_keyboardView在_YYTextKeyboardViewFrameObserver对象dealloc前被释放掉了,导致访问了野指针。很可能两者的关联处理有关系。 场景:并未使用YY相关组件,而是使用了UITextField,调起了键盘。YYTextKeyboardManager单例收到了UIKeyboardDidChangeFrameNotification通知,最后导致的崩溃。

    opened by zhazhaYang 3
  • YYTextView和YYLabel TapAction不响应

    YYTextView和YYLabel TapAction不响应

    为YYTextView设置了YYTextHighlight后,tapAction没有响应,而如果同时设置了tapAction和YYTextView的delegate的话,代理也没有响应,只有屏蔽tapAction后代理才有响应回调,但delegate也是需要用力按压才有响应; 同时YYLabel的tapAction也没有任何响应。 看这个问题已经有很多人反映了,到现在还没有解决方案

    opened by vchao 2
  • iOS16 创建YYTextView后 导致旋转屏幕失败

    iOS16 创建YYTextView后 导致旋转屏幕失败

    UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [UIWindowSceneGeometryPreferencesIOS.alloc initWithInterfaceOrientations:1 << orientation]; [ws requestGeometryUpdateWithPreferences:geometryPreferences errorHandler:^(NSError * _Nonnull error) { }];

    创建YYTextView后,requestGeometryUpdateWithPreferences方法的block会返回错误

    opened by q858333 5
Releases(1.0.6)
  • 1.0.6(Sep 13, 2016)

    • 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
    Source code(tar.gz)
    Source code(zip)
  • 1.0.5(Apr 21, 2016)

  • 1.0.4(Apr 21, 2016)

  • 1.0.3(Apr 21, 2016)

  • 1.0.2(Apr 21, 2016)

    • iOS 9.2 compatible
    • Remove YYDispatchQueuePool due to dynamic library compile error
    • Copy observers before enumerate in YYKeyboardManager
    • Support opaque layer's background color for YYAsyncLayer
    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Apr 21, 2016)

Owner
null
A rich-text editor for iOS

DTRichTextEditor This project aims to provide a replacement for Apple's severely limited UITextView and to allow for editing attributed strings. It co

Cocoanetics 346 Oct 8, 2022
A beautiful rich text WYSIWYG editor for iOS with a syntax highlighted source view

ZSSRichTextEditor The Editor ZSSRichTextEditor is a beautiful Rich Text WYSIWYG Editor for iOS. It includes all of the standard editor tools one would

Nic Hubbard 3.7k Dec 31, 2022
RichEditorView is a simple, modular, drop-in UIView subclass for Rich Text Editing.

RichEditorView RichEditorView is a simple, modular, drop-in UIView subclass for Rich Text Editing. Written in Swift 4 Supports iOS 8+ through Cocoapod

Caesar Wirth 1.8k Dec 24, 2022
Rich Markdown editing control for iOS

MarkdownTextView Rich Markdown Editing for iOS MarkdownTextView is an iOS framework for adding rich Markdown editing capabilities. Support for Markdow

Indragie Karunaratne 676 Dec 7, 2022
More powerful label, attributed string builder and text parser.

DDText More powerful label, attributed string builder and text parser. DDLabel More powerful label than UILabel, using TextKit. It supports features b

Daniel 16 Nov 8, 2022
Twitter Text Libraries. This code is used at Twitter to tokenize and parse text to meet the expectations for what can be used on the platform.

twitter-text This repository is a collection of libraries and conformance tests to standardize parsing of Tweet text. It synchronizes development, tes

Twitter 2.9k Dec 27, 2022
An iOS app to turn typed text into images of handwritten text in your own handwriting style.

Text-to-Handwritting © 2021 by Daniel Christopher Long An iOS app to turn typed text into images of handwritten text in your own handwriting style. ht

Daniel Long 11 Dec 29, 2022
VEditorKit - Lightweight and Powerful Editor Kit built on Texture(AsyncDisplayKit)

VEditorKit provides the most core functionality needed for the editor. Unfortunately, When combined words are entered then UITextView selectedRange will changed and typingAttribute will cleared. So, In combined words case, Users can't continue typing the style they want.

David Ha 471 Dec 27, 2022
Swift String Validator. Simple lib for ios to validate string and UITextFields text for some criterias

Swift String validator About Library for easy and fastest string validation based on сciterias. Instalation KKStringValidator is available through Coc

Kostya 17 Dec 21, 2019
🌍⏩📄 Convert ISO8859 1-16 Encoded Text to String in Swift. Supports iOS, tvOS, watchOS and macOS.

ISO8859 Convert ISO8859 1-16 Encoded Text to String in Swift. Usage let encoding = ISO8859.part1 let string = String([...], iso8859Encoding: encoding)

Devran Cosmo Uenal 18 Jan 2, 2023
Fully open source text editor for iOS written in Swift.

Edhita Fully open source text editor for iOS written in Swift. http://edhita.bornneet.com/ What Edhita means? Edhita (Romaji) == エディタ (Katakana) == Ed

Tatsuya Tobioka 1.2k Jan 1, 2023
Like a SwiftUI ViewBuilder, but for Text

TextBuilder Introduction Text composition in SwiftUI can often be cumbersome, especially when there's logic affecting its format and content. TextBuil

David Roman 180 Dec 26, 2022
Get any text on your screen into your clipboard.

macOCR macOCR is a command line app that enables you to turn any text on your screen into text on your clipboard. When you envoke the ocr command, a "

Marcus S 1.9k Dec 29, 2022
A lightning fast, native SwiftUI scratchpad/text editor.

Sedit A lightning fast, native SwiftUI scratchpad/text editor. Sedit (Swift Edit, as in the language and as in fast) is a lightning fast basic text ed

null 5 Jan 28, 2022
Convert text with HTML tags, links, hashtags, mentions into NSAttributedString. Make them clickable with UILabel drop-in replacement.

Atributika is an easy and painless way to build NSAttributedString. It is able to detect HTML-like tags, links, phone numbers, hashtags, any regex or

Pavel Sharanda 1.1k Jan 8, 2023
Automatic summarizer text in Swift

Overview Reductio is a tool used to extract keywords and phrases using an implementation of the algorithm TextRank. Installation Swift Package Manager

Sergio Fernández 438 Dec 9, 2022
Magnifying glass for text fields

Loupe Magnifying glass for text fields. Apple removed the maginifying glass when selecting texts since iOS 13, this tweak will brings it back. Compati

null 9 Dec 24, 2022
Acčento is an easy-to-use tool for adding Czech diacritics to copied text.

Acčento is an easy-to-use tool for adding Czech diacritics to copied text. The app lives in the menu bar and is activated using a global hot key.

Matty Cross 3 Sep 16, 2021
A small utility to paste text to the clipboard on a jailbroken iPhone

pbpaste allows you to paste text from your iPhone's terminal app to the clipboard. How to use pbpaste Download the file in the binary folder. Copy the

Jay 2 Sep 22, 2021