NSMutableAttributedString *attri = [[NSMutableAttributedString alloc] initWithString:teamInfo.name];
NSTextAttachment *attch = [[NSTextAttachment alloc] init];
if (teamInfo.type == TSessionTeamTypeNormal) {
attch.image = [UIImage imageNamed:@"team_name_tag_normal"];
}else if (teamInfo.type == TSessionTeamTypeClock) {
attch.image = [UIImage imageNamed:@"team_name_tag_checkin"];
}else if (teamInfo.type == TSessionTeamTypeDelegate) {
attch.image = [UIImage imageNamed:@"team_name_tag_contract"];
}
attch.bounds = CGRectMake(5, -2, 30, 16);
NSAttributedString *string = [NSAttributedString attributedStringWithAttachment:attch];
[attri appendAttributedString:string];
// [attri insertAttributedString:string atIndex:0];
_lblTitle.attributedText = attri;
网友评论