πCRTagsLabel generated tag by the attributedText.
You're probably curious how it looks. Here you are:
Create a subclass of CRTagsView
to dispay tag , override -setupTagsViewWithModel:
to set model.
- (void)setupTagsViewWithModel:(id)model {
CRModel *tag = (CRModel *)model;
NSString *title = tag.title;
self.label.attributedText = [self cr_attributedString:title];
}
Create CRTagsLabel
in UIViewController, config block
and tags
.
NSAttributedString *(^block)() = ^NSAttributedString *() {
CRCustomTagsView *customTagView = [CRCustomTagsView new];
return [customTagView attributedStringWithTags:tags];
};
CRTagsLabel *tagsLabel = [[CRTagsLabel alloc] initWithBlock:block];
tagsLabel.tags = tags;
[self.view addSubview:tagsLabel];
[tagsLabel mas_makeConstraints:^(MASConstraintMaker *make) {
make.top.equalTo(@100);
make.left.equalTo(@10);
make.right.equalTo(@-10);
}];
- iOS 8.0+
- ARC
- add to CocoaPods
Issues and pull requests are welcome!
Lcrnice @Lcrnice
CRTagsLabel is released under an MIT license. See LICENSE for more information.