实现每个点赞用户点击的带属性的字符串
生活随笔
收集整理的這篇文章主要介紹了
实现每个点赞用户点击的带属性的字符串
小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
2019獨(dú)角獸企業(yè)重金招聘Python工程師標(biāo)準(zhǔn)>>>
#pragma?mark?-?點(diǎn)擊各個(gè)點(diǎn)贊用戶-(void)setClicked:(TweetCell?*)cell?andOSCTweet:(OSCTweet?*)tweet {NSMutableAttributedString?*attributedString?=?[[NSMutableAttributedString?alloc]?initWithString:tweet.likeListString];//遍歷每個(gè)點(diǎn)贊用戶的名稱for?(int?i?=?0;?i?<?3?&&?i?<?tweet.likeCount;?i++){OSCUser?*user?=?tweet.likeList[i];NSRange?nameRange?=?[tweet.likeListString?rangeOfString:user.name];[attributedString?addAttribute:NSForegroundColorAttributeName?value:[UIColor?nameColor]?range:nameRange];[cell.likeListLabel?addLinkToURL:[NSURL?URLWithString:[NSString?stringWithFormat:@"userid:%lld",?user.userID]]?withRange:nameRange];}NSRange?numRange?=?[tweet.likeListString?rangeOfString:[NSString?stringWithFormat:@"%d人",?tweet.likeCount]];[attributedString?addAttribute:NSForegroundColorAttributeName?value:[UIColor?nameColor]?range:numRange];[cell.likeListLabel?addLinkToURL:[NSURL?URLWithString:[NSString?stringWithFormat:@"tweetid:%lld",?tweet.tweetID]]?withRange:numRange];cell.likeListLabel.attributedText?=?attributedString;cell.likeListLabel.delegate?=?self;} #pragma?mark?-?TTTAttributedLabelDelegate -?(void)attributedLabel:(TTTAttributedLabel?*)label?didSelectLinkWithURL:(NSURL?*)url {NSArray?*arrayStr?=?[url.absoluteString?componentsSeparatedByString:@":"];if?([arrayStr[0]?isEqualToString:@"userid"])?{UserDetailsViewController?*userDetailsVC?=?[[UserDetailsViewController?alloc]?initWithUserID:((NSNumber?*)arrayStr[1]).longLongValue];[self.navigationController?pushViewController:userDetailsVC?animated:YES];}?else?{TweetsLikeListViewController?*likeListCtl?=?[[TweetsLikeListViewController?alloc]?initWithtweetID:((NSNumber?*)arrayStr[1]).longLongValue];[self.navigationController?pushViewController:likeListCtl?animated:YES];}}轉(zhuǎn)載于:https://my.oschina.net/pingAds/blog/416401
總結(jié)
以上是生活随笔為你收集整理的实现每个点赞用户点击的带属性的字符串的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: UCF转XDC工具说明文档
- 下一篇: 2015年总结2016展望