NudeIn 1.2.8

NudeIn 1.2.8

HJ-Cai 维护。



NudeIn 1.2.8

  • HJ-Cai

NudeIn

Build Status Cocoapods Platform Language

NudeIn 是一个基于 UITextView 的 iOS 端富文本控件,其书写风格类似于 Masonry。它采用优雅的声明式(链式)方法定义富文本控件,与编程式方法不同,它所需的代码量相当短,且非常直观易用。

同时,NudeIn 不止于此,它是一款非常灵性的富文本控件,将减少代码冗余提升到极致。例如,考虑到富文本中可能有多于 2 个风格一致的富文本,以及可能仅有部分风格一致的富文本(例如字体大小不一样,颜色不一样)。按照常规编写这些代码,可能会产生大量重复的代码段。为了解决这个问题,NudeIn 引入了 模板,您可以轻松声明一个模板并将其应用于任何需要的组件,同时每个组件甚至可以声明自己的属性来覆盖模板属性,实现部分一致性。这正是 NudeIn 非常灵活的地方。

与其他第三方富文本库相比,NudeIn 将更符合人类的思维方式,使用它不会花费您太多的学习成本。如果您有 Masonry 经验,您将几乎没有学习成本;如果您没有,也无需担心,它看起来像是专门为您的思维方式设计的,只需稍加查看示例,就可以完全学会如何使用它。

用法

NudeIn 的用法非常简单明了,这里提供一个非常简单的例子,相信您会被这样的用法惊艳到,一旦尝试使用它,就会爱上它。

1、引入控件

#import "NudeIn.h"

2、声明控件为你的成员变量

@property (nonatomic,strong) NudeIn *attrLabel;

3、自行设定

_attrLabel = [NudeIn make:^(NUDTextMaker *make) {
    make.text(@"this is a ").font(14).color([UIColor blackColor]).attach();
    make.text(@"BlueLink").font(17).color([UIColor blueColor]).link(self,@selector(linkHandler:)).attach();
    make.text(@", and this is a ").font(14).color([UIColor blackColor]).attach();
    make.text(@"RedLink").font(17).color([UIColor redColor]).link(self,@selector(linkHandler:)).attach();
}];

3、为声明了 link 属性的部分定义回调

- (void)linkHandler:(NUDAction *)action {
    
    if ([action isKindOfClass:[NUDLinkAction class]]) {
        
        NUDLinkAction *linkAction = (NUDLinkAction *)action;
        
        UIAlertController *alertController = [UIAlertController alertControllerWithTitle:linkAction.string message:nil preferredStyle:UIAlertControllerStyleAlert];
    
        [alertController addAction:[UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
        }]];
        
        [self presentViewController:alertController animated:YES completion:nil];
        
    }
    
}

结果将如下所示:

点击带有 link 属性的部分,将产生回调:

安装

pod 'NudeIn'

最新 pod 版本:1.2.4

1、增加了一个全局模板的 makeTemplate 功能。

2、优化了 shadow 属性。

3、新增了 tap 属性,现在 text 可以声明 tap,引入回调,此属性可以替代 link 属性。

4、修复了一部分错误和 bug。

5、为 image 组件添加了 alignment 功能,可以在一行中为 image 声明对齐类型。

最低 iOS 版本: 8.0

索引

  • 文本

    • 字体 通过大小声明字体,统一使用系统字体

    • fontName 通过字体名以及大小声明字体

    • fontRes 通过 UIFont 声明字体

    • fontStyle 声明字体的风格,如 Bold、Light 等

    • bold 声明字体为 Bold 风格,如果有的话

    • color 声明文字的前景色

    • mark 声明文字的底色

    • hollow 声明文字为镂空

    • solid 声明文字为实心

    • link 声明文字为链接文字

    • _ 声明文字带下划线

    • deprecated 声明文字带删除线

    • skew 声明文字为斜体

    • kern 声明文字的紧凑程度

    • ln 声明文字换行

    • ligature 声明文字为连体字

    • letterpress 声明文字为印刷风格(凸起效果),该属性占用内存较高,请谨慎使用

    • vertical 声明文字的垂直偏移

    • stretch 声明文字的水平拉伸程度(可能引起变形)

    • reverse 声明文字逆序书写

    • shadow 声明文字带默认阴影

    • shadowDirection 声明文字带阴影,并且设定阴影为八个基本方向

    • shadowOffset 声明文字带阴影,并且完全自定义阴影的方向

    • shadowBlur 声明文字带阴影,并自定义阴影的模糊程度

    • shadowColor 声明文字带阴影,并自定义阴影颜色

    • shadowRes 通过 NSShadow 声明并自定义阴影

    • lineSpacing 声明文字的行距

    • lineHeight 声明文字的行高(最小行高,最大行高,行高倍数)

    • paraSpacing 声明文字每个自然段与其他自然段拉开的间距(与前文的间距,与后文的间距)

    • aligment 声明文字的对齐方式,参数为 NUDAlignment

    • indent 声明文字的缩进(前缩进,后缩进)

    • fl_headIndent 声明文字的首行前缩进,该属性会在首行覆盖 indent 的前缩进属性

    • linebreak 声明文字的断行方式,参数为 NUDLineBreakMode

    • highlight 声明文字的触摸高亮,参数为一个模板的 id

    • tap 声明文字的触摸回调,参数为回调的 target 以及回调方法

  • 图片

    • origin 声明图像的偏移,锚点为左下角

    • size 声明图像的大小

    • ln 声明图像换行

    • aligment 声明图像对齐属性,参数为 NUDAligment

  • 模板

    • textTemplate 声明一个 text 模板,以参数 identifier 来标识这个模板以便重复使用,其使用方法和 text 相同

    • imageTemplate 声明一个 image 模板,以参数 identifier 来标识这个模板以便重复使用,其使用方法和 image 相同

    • allText 声明所有使用 .attach() 的 text 都会被附加的属性,使用 .attachWith(@"") 不受影响

    • allImage 声明所有使用 .attach() 的 image 都会被附加的属性,使用 .attachWith(@"") 不受影响

  • makeTemplate

    • textTemplate 全局声明一个 text 模板,以参数 identifier 来标识这个模板以便重复使用,其使用方法和 text 相同

    • imageTemplate 全局声明一个 image 模板,以参数 identifier 来标识这个模板以便重复使用,其使用方法和 image 相同

    • allText 全局声明所有使用 .attach() 的 text 都会被附加的属性,使用 .attachWith(@"") 不受影响

    • allImage 全局声明所有使用 .attach() 的 image 都会被附加的属性,使用 .attachWith(@"") 不受影响

文档

font

font 默认使用系统字体,如果只使用系统字体,它会让你的代码更简洁一些

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.text(@"Github.com").font(32).attach();
}];

fontName

fontName 使用字体名称来设定字体,字体的名称可以是默认的 family 名称,也可以是特定粗细的字体名称

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.text(@"Github.com").fontName(@"AmericanTypewriter",32).ln(1).attach();
    make.text(@"Github.com").fontName(@"AmericanTypewriter-Bold",32).attach();
}];

fontRes

fontRes 使用自定义的 UIFont 来设定字体,这里可以任由您的选择

UIFont *font = [UIFont fontWithName:@"AmericanTypewriter" size:32];
UIFont *fontBold = [UIFont fontWithName:@"AmericanTypewriter-Bold" size:32];
NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.text(@"Github.com").fontRes(font).ln(1).attach();
    make.text(@"Github.com").fontRes(fontBold).attach();
}];

字体样式

字体样式 可以更方便地设定字体的风格,不过需要注意的是,这些需要与字体名称相匹配,如NUDBold风格,需要相应字体有-Bold后缀,否则该方法将无效。

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.text(@"Github.com").fontName(@"AmericanTypewriter",32).fontStyle(NUDBold).attach();
}];

加粗

加粗 考虑到加粗较为常用,将其作为属性来使用也许会更加清晰,其效果等同于字体样式

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.text(@"Github.com").fontName(@"AmericanTypewriter",32).bold().attach();
}];

颜色

颜色 用于设定文字颜色,传入 UIColor 即可。

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().fontName(@"AmericanTypewriter",32).bold().attach();
    make.text(@"G").color([UIColor orangeColor]).attach();
    make.text(@"i").color([UIColor redColor]).attach();
    make.text(@"t").color([UIColor blueColor]).attach();
    make.text(@"h").color([UIColor magentaColor]).attach();
    make.text(@"u").color([UIColor brownColor]).attach();
    make.text(@"b").color([UIColor greenColor]).attach();
}];

标记

标记 用于设定文字的底色,就如同在书本上为某一行文字涂上马克笔一样,这样看起来比较直观。

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().fontName(@"AmericanTypewriter",32).color([UIColor whiteColor]).bold().attach();
    make.text(@"G").mark([UIColor orangeColor]).attach();
    make.text(@"i").mark([UIColor redColor]).attach();
    make.text(@"t").mark([UIColor blueColor]).attach();
    make.text(@"h").mark([UIColor magentaColor]).attach();
    make.text(@"u").mark([UIColor brownColor]).attach();
    make.text(@"b").mark([UIColor greenColor]).attach();
}];

空心

空心 可以使文字呈现镂空效果,类似于艺术字,第一个参数可以设置边框的粗细,第二个参数可以设定颜色。

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().fontName(@"AmericanTypewriter",32).bold().attach();
    make.text(@"G").hollow(4,[UIColor orangeColor]).attach();
    make.text(@"i").hollow(4,[UIColor redColor]).attach();
    make.text(@"t").hollow(4,[UIColor blueColor]).attach();
    make.text(@"h").hollow(4,[UIColor magentaColor]).attach();
    make.text(@"u").hollow(4,[UIColor brownColor]).attach();
    make.text(@"b").hollow(4,[UIColor greenColor]).attach();
}];

实心

实心 表示其为实心的,这样的话,我们可以自定义填充颜色,使字体看起来更有艺术感

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().fontName(@"AmericanTypewriter",64).bold().color([UIColor cyanColor]).attach();
    make.text(@"G").solid(4,[UIColor orangeColor]).attach();
    make.text(@"i").solid(4,[UIColor redColor]).attach();
    make.text(@"t").solid(4,[UIColor blueColor]).attach();
    make.text(@"h").solid(4,[UIColor magentaColor]).attach();
    make.text(@"u").solid(4,[UIColor brownColor]).attach();
    make.text(@"b").solid(4,[UIColor greenColor]).attach();
}];

链接

链接 可以使文字变成链接,点击该链接后会调用指定的方法。而在点击链接时,链接的背景会被设置为灰色。

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.text(@"Github.com").font(64).link(self,@selector(linkHandler:)).color([UIColor blueColor])._(NUD_,[UIColor blueColor]).attach();
}];

_

_ 顾名思义,即为下划线,使用它可以为你添加下划线的文字。

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().fontName(@"AmericanTypewriter",32).bold().ln(1).color([UIColor cyanColor]).attach();
    make.text(@"Github")._(NUD_,[UIColor blueColor]).attach();
    make.text(@"Github")._(NUD__,[UIColor blackColor]).attach();
    make.text(@"Github")._(NUDThick_,[UIColor blueColor]).attach();
    make.text(@"Github")._(NUDDot,[UIColor blueColor]).attach();
    make.text(@"Github")._(NUDDotDot,[UIColor blueColor]).attach();
    make.text(@"Github")._(NUDDash,[UIColor blueColor]).attach();
    make.text(@"Github")._(NUDDashDot,[UIColor blueColor]).attach();
    make.text(@"Github")._(NUDDashDotDot,[UIColor blueColor]).attach();
    make.text(@"Github com")._(NUDDashDotDot|NUDByWord,[UIColor blueColor]).attach();
}];

已弃用

已弃用 加入删除线,表示该文字已经被删除了或者是被废弃了,相对来说可读性高一些

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.text(@"Github.com").font(64).deprecated([UIColor blackColor]).attach();
}];

skew

skew 给文字加斜度,斜度根据传入的 CGFloat 值的大小决定其斜度

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().fontName(@"AmericanTypewriter",32).bold().ln(1).aligment(NUDAliCenter).attach();
    make.text(@"Github.com").skew(0.0).attach();
    make.text(@"Github.com").skew(0.2).attach();
    make.text(@"Github.com").skew(0.4).attach();
    make.text(@"Github.com").skew(0.8).attach();
    make.text(@"Github.com").skew(1).attach();
    make.text(@"Github.com").skew(1.2).attach();
}];

kern

kern 设定文字的紧凑程度,根据传入的 CGFloat 值的大小决定其紧凑度

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().fontName(@"AmericanTypewriter",32).bold().ln(1).aligment(NUDAliCenter).attach();
    make.text(@"Github.com").kern(0.0).attach();
    make.text(@"Github.com").kern(0.2).attach();
    make.text(@"Github.com").kern(0.4).attach();
    make.text(@"Github.com").kern(0.8).attach();
    make.text(@"Github.com").kern(1).attach();
    make.text(@"Github.com").kern(1.2).attach();
}];

ln

ln 设定该组件换行,使用该属性可以无需手动在text里添加\n,并且传入大于1的整数还可以多次换行,特别要注意的是,换行符的属性也和该组件的其他字符串等同

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.text(@"Github.com").font(32).ln(2).attach();
    make.text(@"Github.com").font(16).ln(2).attach();
    make.text(@"Github.com").font(32).attach();
}];

ligature

ligature 声明文字为连体,使用之后,字体将会带有连体书写的效果,特别要注意的是,该属性只对部分支持连体的字母组以及字体有效

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.text(@"This is a attributed string").fontName(@"zapfino",23).ligature(NO).ln(1).attach();
    make.text(@"This is a attributed string").fontName(@"zapfino",23).ligature(YES).attach();
}];

letterpress

letterpress 声明文字带有印刷效果,

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.text(@"Github.com").font(64).letterpress().ln(1).attach();
    make.text(@"Github.com").font(64).ln(1).attach();
}];

vertical

vertical 会让文字在垂直方向有一个偏移,传入一个CGFloat,如果大于0,则往上偏移,如果小于0,则往下偏移

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.text(@"Github").font(64).attach();
    make.text(@"[1]").font(15).color([UIColor blueColor]).vertical(35).ln(1).attach();
    make.text(@"Github").font(64).attach();
    make.text(@".com").font(32).color([UIColor orangeColor]).vertical(-20).attach();
}];

拉伸

拉伸 使文字在水平方向上拉伸,拉伸程度取决于传入的CGFloat值,换句话说,值越小,文字越扁,值越大,文字越长

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.text(@"Github").font(64).ln(1).attach();
    make.text(@"Github").font(64).stretch(0.5).ln(1).attach();
    make.text(@"Github").font(64).stretch(-0.5).attach();
}];

反转

反转 使文字呈现逆序书写效果

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.text(@"Github").font(64).ln(1).attach();
    make.text(@"Github").font(64).reverse().attach();
}];

阴影

阴影 使文字带上默认阴影效果,该效果使文字略显凸起

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.text(@"Github").font(64).color([UIColor whiteColor]).shadow().attach();
}];

阴影方向

阴影方向 使文字带上默认阴影效果,并且可以定义阴影的四个基本方向:上下左右。第二个参数用于定义阴影的突出程度。需要注意的是,在使用autolayout布局控件时,控件并不会因为阴影而自动调整frame大小,这时候可能需要手动调整。

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().font(64).color([UIColor orangeColor]).aligment(NUDAliCenter).ln(1).attach();
    make.text(@"Github").shadowDirection(NUDLeft,10).attach();
    make.text(@"Github").shadowDirection(NUDRight,10).attach();
    make.text(@"Github").shadowDirection(NUDBottom,10).attach();
    make.text(@"Github").shadowDirection(NUDTop,10).attach();
}];

阴影偏移

阴影偏移 使文字带上默认阴影效果,并且可以完全自定义阴影的延伸方向

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().font(64).color([UIColor orangeColor]).aligment(NUDAliCenter).ln(1).attach();
    make.text(@"Github").shadowOffset(-5,-5).attach();
    make.text(@"Github").shadowOffset(5,5).attach();
    make.text(@"Github").shadowOffset(-5,5).attach();
    make.text(@"Github").shadowOffset(5,-5).attach();
}];

阴影模糊

阴影模糊 使文字带上默认阴影效果,并且可以完全自定义阴影的模糊程度。该值越大,阴影越模糊,给人一种文字与阴影距离越远的感觉

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().font(64).color([UIColor orangeColor]).shadowOffset(20,0).aligment(NUDAliCenter).ln(1).attach();
    make.text(@"Github").shadowBlur(0).attach();
    make.text(@"Github").shadowBlur(2).attach();
    make.text(@"Github").shadowBlur(4).attach();
    make.text(@"Github").shadowBlur(8).attach();
}];

阴影颜色

阴影颜色 使文字带上默认阴影效果,并且可以自定义阴影的颜色

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().shadowDirection(NUDRight,15).font(64).shadowBlur(3).color([UIColor orangeColor]).ln(1).attach();
    make.text(@"Github").shadowColor([UIColor redColor]).attach();
    make.text(@"Github").shadowColor([UIColor blueColor]).attach();
    make.text(@"Github").shadowColor([UIColor greenColor]).attach();
    make.text(@"Github").shadowColor([UIColor orangeColor]).attach();
}];

shadowRes

shadowRes 允许文字带有自定义的阴影效果,你可以传递 NSShadow来自定义阴影。

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    NSShadow *shadow = [[NSShadow alloc] init];
    shadow.shadowOffset = CGSizeMake(8, 0);
    shadow.shadowColor = [UIColor redColor];
    shadow.shadowBlurRadius = 3;
    make.text(@"Github").shadowRes(shadow).font(64).attach();
}];

lineSpacing

lineSpacing 允许声明文字换行时的行距。

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().font(32).color([UIColor orangeColor]).ln(1).attach();
    make.text(@"Github").lineSpacing(0).attach();
    make.text(@"Github").lineSpacing(8).attach();
    make.text(@"Github").lineSpacing(16).attach();
    make.text(@"Github").lineSpacing(32).attach();
}];

lineHeight

lineHeight 声明文字的行高,需要注意这里有三个参数:

minimumLineHeight 为第一个参数,它定义一行的小高度,也就是说,只要该值不为 0,则行高至少为 minimumLineHeight

maximumLineHeight 为第二个参数,它定义一行的大高度,也就是说,只要该值不为 0,则行高最大为 maximumLineHeight

lineHeightMultiple 为第三个参数,它定义一行行高的倍数,也就是说,如果该值不为 0,则会基于原始的行高乘以 lineHeightMultiple

一行的高并不只取决于 lineHeightMultiple,如果你限制了 minimumLineHeightmaximumLineHeight,即使设定过大的 lineHeightMultiple,也不会超出你所限制的范围。

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().font(32).color([UIColor orangeColor]).ln(1).attach();
    make.text(@"Github").lineHeight(0,0,4).mark([UIColor redColor]).attach();
    make.text(@"Github").lineHeight(0,100,4).mark([UIColor blueColor]).attach();
    make.text(@"Github").lineHeight(100,0,0).mark([UIColor greenColor]).attach();
    make.text(@"Github").lineHeight(100,0,1).mark([UIColor blueColor]).attach();
    make.text(@"Github").lineHeight(100,0,4).mark([UIColor redColor]).attach();
}];

paraSpacing

paraSpacing 允许在文字换行时产生额外的间距,包含两个参数:第一个参数为上间距,第二个参数为下间距。

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().font(32).color([UIColor orangeColor]).ln(1).attach();
    make.text(@"Github").paraSpacing(20,20).mark([UIColor redColor]).attach();
    make.text(@"Github").paraSpacing(20,30).mark([UIColor blueColor]).attach();
    make.text(@"Github").paraSpacing(30,40).mark([UIColor greenColor]).attach();
    make.text(@"Github").paraSpacing(40,50).mark([UIColor blueColor]).attach();
    make.text(@"Github").paraSpacing(50,60).mark([UIColor redColor]).attach();
}];

aligment

aligment 定义文字的对齐方式。

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().font(32).color([UIColor orangeColor]).mark([UIColor greenColor]).ln(1).attach();
    make.text(@"Github").aligment(NUDAliLeft).attach();
    make.text(@"Github").aligment(NUDAliCenter).attach();
    make.text(@"Github").aligment(NUDAliRight).attach();
}];

indent

indent 定义文字的缩进,第一个参数为前缩进,第二个参数为后缩进。

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().font(17).color([UIColor orangeColor]).mark([UIColor blueColor]).ln(2).indent(30,20).attach();
    make.text(@"GitHub Inc. is a web-based hosting service for version control using Git.").attach();
    make.text(@"It is mostly used for computer code.").indent(60,0).attach();
    make.text(@"It offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features.").indent(0,60).attach();
    make.text(@"It provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project.").attach();
}];

fl_headIndent

fl_headIndent 定义文字的首行缩进,如果你定义过 indent 属性,它会在首行覆盖 indent 属性的前缩进属性

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().font(17).color([UIColor orangeColor]).mark([UIColor blueColor]).ln(1).fl_headIndent(40).attach();
    make.text(@"GitHub Inc. is a web-based hosting service for version control using Git. ").attach();
    make.text(@"It is mostly used for computer code. ").attach();
    make.text(@"It offers all of the distributed version control and source code management (SCM) functionality of Git as well as adding its own features.").attach();
    make.text(@"It provides access control and several collaboration features such as bug tracking, feature requests, task management, and wikis for every project.").attach();
}];

linebreak

linebreak 定义文字的换行方式

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.allText().font(17).color([UIColor orangeColor]).mark([UIColor blueColor]).ln(2).attach();
    make.text(@"It is mostly used for computer code.").linebreak(NUDWord).attach();
    make.text(@"It is mostly used for computer code.").linebreak(NUDChar).attach();
    make.text(@"It is mostly used for computer code.").linebreak(NUDClip).attach();
    make.text(@"It is mostly used for computer code.").linebreak(NUDTr_head).attach();
    make.text(@"It is mostly used for computer code.").linebreak(NUDTr_tail).attach();
    make.text(@"It is mostly used for computer code.").linebreak(NUDTr_middle).attach();
}];

highlight

highlight 定义文字高亮,通过传入模板,可以定义高亮时文字的属性

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.textTemplate(@"Highlight").color([UIColor greenColor]).font(64).attach();
    make.text(@"Github").font(64).color([UIColor blackColor]).highlighted(@"Highlight").attach();
}];

tap

tap 定义文字单击所产生的回调,该属性和 link 属性的效果是一致的,不过相比link属性,它的单击区域紧紧限制在文字之内,并且配合highlight方法,你可以做到完全自定义单击风格

NudeIn *nude = [NudeIn make:^(NUDTextMaker *make) {
    make.textTemplate(@"Highlight").color([UIColor greenColor]).font(64).attach();
    make.text(@"Github").font(64).color([UIColor blackColor]).highlighted(@"Highlight").tap(self,@selector(linkHandler:)).attach();
}];

许可协议

NudeIn 采用 MIT 许可协议发布。有关详细信息,请参阅许可协议