Commit f06178b8 cgx

优化文章标签显示

1 个父辈 c9de7bfe
......@@ -55,7 +55,17 @@
self.contentLab.text = model.content;
[self.coverIV yy_setImageWithURL:[NSURL URLWithString:model.cover] placeholder:[UIImage defaultPlaceholderWithSize:CGSizeMake(86, 86)]];
// tag标签最多只有3个
NSArray *tagsTitleArr = model.tags ? [model.tags componentsSeparatedByString:@"|"] : @[];
NSArray *tagTitleColors = @[BrandColor];
NSArray *tagBgColors = @[ColorFromHexA(0x62C3D5, .2)];
if (tagsTitleArr.count == 2) {
tagTitleColors = @[BrandColor, ColorFromHex(0x9377FC)];
tagBgColors = @[ColorFromHexA(0x62C3D5, .2), ColorFromHexA(0x9377FC, .2)];
} else if (tagsTitleArr.count == 3) {
tagTitleColors = @[BrandColor, ColorFromHex(0x9377FC), ColorFromHex(0x5E9EFC)];
tagBgColors = @[ColorFromHexA(0x62C3D5, .2), ColorFromHexA(0x9377FC, .2), ColorFromHexA(0x5E9EFC, .2)];
}
[self.tagsView.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[obj removeFromSuperview];
}];
......@@ -63,10 +73,10 @@
for (int idx = 0; idx < tagsTitleArr.count; idx++) {
NSString *tagTitle = [NSString stringWithFormat:@"#%@", tagsTitleArr[idx]];
CGFloat tagTitleW = [UILabel getWidthWithText:tagTitle font:SysFont(12)] + 16;
UILabel *tagLab = [UILabel labWithTextColor:BrandColor font:SysFont(12)];
UILabel *tagLab = [UILabel labWithTextColor:tagTitleColors[idx] font:SysFont(12)];
tagLab.text = tagTitle;
tagLab.textAlignment = NSTextAlignmentCenter;
tagLab.backgroundColor = ColorFromHexA(0x62C3D5, .2);
tagLab.backgroundColor = tagBgColors[idx];
[tagLab cornerRadius:10.5];
tagLab.frame = CGRectMake(totalW + idx * 8, 0, tagTitleW, 21);
totalW += tagTitleW;
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!