yylabel html富文本,YYText

YYText是一个强大的iOS文本框架,用于显示和编辑富文本。它与UILabel和UITextView API兼容,支持高效率的异步文本布局和渲染,扩展了CoreText属性,提供了文本附件、自定义高亮、文本解析等功能。此外,还支持文本容器路径、垂直表单布局、图像和属性文本复制粘贴等特性。
摘要由CSDN通过智能技术生成

YYText

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

c35e98dcbcfe3cb969baf527764fffcf.png

Text Attributes

YYText supported attributes

Demo

Attribute Name

Class

b083e067b651ff402a5b335709fb4711.gif

TextAttachment

YYTextAttachment

2bb2e722489f15053c040410c71c05d5.gif

TextHighlight

YYTextHighlight

YYTextBinding.gif

TextBinding

YYTextBinding

e0b82de9fc1a91a9ae9d2f3760720d5f.png

TextShadow

TextInnerShadow

YYTextShadow

c5e93959ef9fb22acf8d50f5f3e43ca4.png

TextBorder

YYTextBorder

6dab6af815af68b89a44a700eb88c367.png

TextBackgroundBorder

YYTextBorder

ebbe4dcca3434ae3fb7522d5d4b8dea0.png

TextBlockBorder

YYTextBorder

4c375bcbf79e7233d387a493c0d7f501.png

TextGlyphTransform

NSValue(CGAffineTransform)

784d84ebcfdcd4b7d13ea46eb4dd65e8.png

TextUnderline

YYTextDecoration

d2b26bec62c691f72c23ae6685447e10.png

TextStrickthrough

YYTextDecoration

0694a7ccbcda6f0ff8cfffa7ad97448f.png

TextBackedString

YYTextBackedString

###CoreText attributes which is supported by YYText

Demo

Attribute Name

Class

6aa75c3c8cf9ed1206838a5ef2c25ccf.png

Font

UIFont(CTFontRef)

Kern.png

Kern

NSNumber

2232f5e6dd0460f995bafb49e87f33e6.png

StrokeWidth

NSNumber

dbf874903b10e6f50b3177b43c5721c9.png

StrokeColor

CGColorRef

1c575b58504c5ef8d4239d268121ac27.png

Shadow

NSShadow

d5b1b33641f4721321e4a8f6ff2e6df7.png

Ligature

NSNumber

c0d1f0194e1abed83b8f72725fc6cebd.png

VerticalGlyphForm

NSNumber(BOOL)

0f76aae35555e429e83c6904a8c848af.png

WritingDirection

NSArray(NSNumber)

0b9ad45be69e02b964793f09c32d839e.png

RunDelegate

CTRunDelegateRef

Alignment.png TextAlignment NSParagraphStyle
(NSTextAlignment) LineBreakMode.png LineBreakMode NSParagraphStyle
(NSLineBreakMode) LineSpacing.png LineSpacing NSParagraphStyle
(CGFloat) ParagraphSpacing.png ParagraphSpacing
ParagraphSpacingBefore NSParagraphStyle
(CGFloat) FirstLineHeadIndent.png FirstLineHeadIndent NSParagraphStyle
(CGFloat) HeadIndent.png HeadIndent NSParagraphStyle
(CGFloat) TailIndent.png TailIndent NSParagraphStyle
(CGFloat) MinimumLineHeight.png MinimumLineHeight NSParagraphStyle
(CGFloat) MaximumLineHeight.png MaximumLineHeight NSParagraphStyle
(CGFloat) LineHeightMultiple.png LineHeightMultiple NSParagraphStyle
(CGFloat) BaseWritingDirection.png BaseWritingDirection NSParagraphStyle
(NSWritingDirection) Tab.png 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.numberOf

在Bison中,yytext是一个全局变量,用于存放当前解析的token的文本内容。通常情况下,我们可以在Bison的语法规则中通过使用$1、$2等符号来引用yytext,这些符号代表了当前解析的token的文本内容。 例如,假设我们需要解析一个简单的表达式,表达式中只包含加、减、乘、除四种运算符和数字。那么我们可以定义如下的Bison语法规则: ``` %{ #include <stdio.h> %} %token NUMBER %token PLUS %token MINUS %token TIMES %token DIVIDE %% expr: NUMBER | expr PLUS expr | expr MINUS expr | expr TIMES expr | expr DIVIDE expr ; %% int main() { yyparse(); return 0; } int yyerror(const char *msg) { fprintf(stderr, "Error: %s\n", msg); return 0; } int yylex() { int c = getchar(); if (isdigit(c)) { ungetc(c, stdin); scanf("%d", &yylval); return NUMBER; } else if (c == '+') { return PLUS; } else if (c == '-') { return MINUS; } else if (c == '*') { return TIMES; } else if (c == '/') { return DIVIDE; } else if (c == '\n' || c == EOF) { return 0; } else { return -1; } } ``` 在上述代码中,我们定义了一个简单的表达式语法规则,其中每个token都有一个相应的词法分析器函数yylex()来生成。同时,我们还定义了一个yyerror()函数,用于处理语法错误。当Bison解析表达式时,它会自动将当前解析的token的文本内容存放到yytext中,并将其传递到语法规则中。 例如,当我们输入一个简单的表达式"1+2"时,Bison会先调用yylex()函数来获取第一个token,也就是数字"1",然后将其存放到yylval中,并返回NUMBER这个token类型。接下来,Bison会继续调用yylex()函数来获取下一个token,也就是加号"+",然后将其存放到yytext中,并返回PLUS这个token类型。最后,Bison会根据语法规则来解析表达式,并输出结果"3"。 可以看到,在Bison中使用yytext非常简单,我们只需要在语法规则中使用相应的符号$1、$2等来引用yytext即可。如果需要在Bison的代码中直接访问yytext,则可以直接使用全局变量yytext来获取其值。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值