这是一个分词组件.用与文本分词,列表展示.参考Pin的分词界面.和UC的bigbang界面. (该项目是 GRichLabel 文本选择复制功能的组件之一).欢迎大家star!
- 可区分标点符号与表情.
- 可自定义分词展现列表.
- 分词列表支持滑动/点击选择.
- 提供默认分词展现Container.
-(void)bigbang:(NSString*)selection
{
NSArray * array = [GBigbangBox bigBang:selection];
__block NSMutableArray *flows = [NSMutableArray array];
[array enumerateObjectsUsingBlock:^(GBigbangItem * obj, NSUInteger idx, BOOL * _Nonnull stop) {
GTagFlowItem *layout = [GTagFlowItem tagFlowItemWithText:obj.text];
[flows addObject:layout];
if (obj.isSymbolOrEmoji) {
layout.appearance.backgroundColor = [UIColor grayColor];
layout.appearance.textColor = [UIColor blackColor];
}
}];
[self.container configDatas:flows.copy];
[self.container show];
}
self.appearance = [GTagFlowAppearance new];
self.appearance.borderColor = [UIColor blackColor];
self.appearance.textColor = [UIColor blackColor];
self.appearance.borderWidth = 1;
self.appearance.backgroundColor = [UIColor whiteColor];
self.appearance.selectTextColor = [UIColor redColor];
self.appearance.selectBorderColor = [UIColor redColor];
self.appearance.selectBackgroundColor = [UIColor whiteColor];
NSArray *items = [GBigbangBox bigBang:self.string];
NSArray * layouts = [GTagFlowItem factoryFolwLayoutWithItems:items withAppearance:self.appearance];
self.flowView.flowDatas = layouts;
[self.flowView reloadDatas];
GTagFlowContainer *container = [GTagFlowContainer new];
self.container = container;
/// 使用自定义流水布局
[self.container.flowView configTagCollectionViewLayout];
self.container.actionBtnItems = @[@"复制",@"举报",@"错别字"];
self.container.actionBlock = ^(NSString *actionTitle, NSString *newText) {
NSLog(@"点击了 -- %@, 选择的文字 -- %@",actionTitle,newText);
};
NSArray * layouts = [GTagFlowItem factoryFolwLayoutWithItems:items withAppearance:nil];
self.flowView.flowDatas = layouts;
[self.flowView reloadDatas];
- Add
pod 'GBigbang'
to your Podfile. - Run
pod install
orpod update
. - Import "GBigbang.h"
git clone https://github.com/GIKICoder/GBigbang.git
- 选择
GBigbang
文件夹.拖入项目中即可.
- 2017/11/24 : 增加自定义布局Layout. bigbang列表可使用自定义布局. 实现固定间距列表.