https://github.com/zhitrend/seemore
完成查看更多功能,要求与文字同一行。使用yykit,完成查看更多功能
https://github.com/zhitrend/seemore
Last synced: about 1 year ago
JSON representation
完成查看更多功能,要求与文字同一行。使用yykit,完成查看更多功能
- Host: GitHub
- URL: https://github.com/zhitrend/seemore
- Owner: zhitrend
- Created: 2018-05-21T03:17:52.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-13T07:53:01.000Z (about 8 years ago)
- Last Synced: 2024-12-27T08:15:26.236Z (over 1 year ago)
- Language: Objective-C
- Homepage:
- Size: 5.43 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
文字末尾点击查看更多展开所有内容
通过yykit中的yylabel与富文本结合进行处理
```
- (void)addAllButton {
__weak typeof (self) _self = self;
// 需要拼接的内容
NSMutableAttributedString *text = [[NSMutableAttributedString alloc] initWithString:@"...全部"];
// 高亮点击模块 运用在tableview中可和百度开源的FD结合使用自适应cell高度
YYTextHighlight *hi = [YYTextHighlight new];
[hi setColor:[UIColor colorWithRed:0.578 green:0.790 blue:1.000 alpha:1.000]];
hi.tapAction = ^(UIView *containerView,NSAttributedString *text,NSRange range, CGRect rect) {
YYLabel *label = _self.label;
[label sizeToFit];
};
// 全部:文字高亮
[text setColor:[UIColor colorWithRed:0.000 green:0.449 blue:1.000 alpha:1.000]range:[text.string rangeOfString:@"全部"]];
[text setTextHighlight:hi range:[text.string rangeOfString:@"全部"]];
text.font =_label.font;
YYLabel *seeMore = [YYLabel new];
seeMore.attributedText = text;
[seeMore sizeToFit];
// yylebel 添加到原label中
NSAttributedString *truncationToken = [NSAttributedString attachmentStringWithContent:seeMore contentMode:UIViewContentModeCenter attachmentSize:seeMore.frame.size alignToFont:text.font alignment:YYTextVerticalAlignmentCenter];
_label.truncationToken = truncationToken;
}
```

