NudeIniOS 端富文本控件
NudeIn
NudeIn 是一個(gè)基于 UITextView ,書寫風(fēng)格類似于 masonry 的 iOS 端富文本控件,它采用優(yōu)雅的聲明式方法定義富文本控件,和編程式的不同,它所需的代碼量相當(dāng)短,且非常直觀易用。
Usage
NudeIn 的用法非常簡單明了,這里給出一個(gè)非常簡單的例子,相信你會被這樣的用法驚艷到,一旦用起來就會愛不釋手:
1、引入控件
#import "NudeIn.h"
2、聲明控件為你的成員變量
@property (nonatomic,strong) NudeIn *attrLabel;
3、Do it yourself
_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 屬性的部分定義回調(diào)
- (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];
}
}
結(jié)果會是這樣:
點(diǎn)擊帶有 link 屬性的部分,將產(chǎn)生回調(diào):
Installation
pod 'NudeIn' '~> 1.2.1-beta'
最新 pod 版本:1.2.1-beta
目前該版本屬于不穩(wěn)定版本
最低 iOS 版本: 8.0
License
NudeIn is released under the MIT license. See LICENSE for details.
評論
圖片
表情
