Open afishhhhh opened 8 years ago
我放在了一个cell里,结果是这样的
- (void)configure { NSMutableAttributedString *text = [NSMutableAttributedString new]; NSArray *tags = @[@"red", @"orange", @"yellow", @"green", @"blue", @"purple", @"gray"]; for (int i = 0; i < [tags count]; i++) { NSString *tag = [tags objectAtIndex:i]; NSMutableAttributedString *tagText = [[NSMutableAttributedString alloc] initWithString:tag]; tagText.yy_color = [UIColor whiteColor]; [tagText yy_insertString:@" " atIndex:0]; [tagText yy_appendString:@" "]; YYTextBorder *border = [YYTextBorder new]; border.fillColor = [UIColor redColor]; border.cornerRadius = 100; border.lineJoin = kCGLineJoinBevel; border.insets = UIEdgeInsetsMake(-4, -16, -4, -16); [tagText yy_setTextBackgroundBorder:border range:[tagText.string rangeOfString:tag]]; [text appendAttributedString:tagText]; } text.yy_lineSpacing = 10; text.yy_lineBreakMode = NSLineBreakByWordWrapping; text.yy_font = [UIFont systemFontOfSize:18]; YYLabel *label = [YYLabel new]; label.attributedText = text; label.numberOfLines = 0; [self.contentView addSubview:label]; [label mas_makeConstraints:^(MASConstraintMaker *make) { make.edges.equalTo(self.contentView); make.height.mas_equalTo(100); }]; }
@ibireme
@ibireme 希望可以有解决方案,谢谢!
我放在了一个cell里,结果是这样的