TTTAtibutedlabel again
Posted guligei
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了TTTAtibutedlabel again相关的知识,希望对你有一定的参考价值。
NSString *contentStr = [NSString stringWithFormat:@"你和%@还是陌生人,听歌时送花给TA可以开启留言", friendInfo.nickName];
NSMutableAttributedString * tttstring = [[NSMutableAttributedStringalloc] initWithString:contentStr];
UIColor *mColor = RGBCOLOR(224, 108, 0);
[tttstring addAttribute:(NSString*)kCTForegroundColorAttributeName value:(id)[mColor CGColor]range:NSMakeRange(2,friendInfo.nickName.length)];
[interactCell.strangerLb setText:tttstring];
-(void)awakeFromNib
{
self.mTitleLabel.delegate = self;
}
-(void)setInfo:(CashInfo *)info
{
NSMutableString *mStr = [[NSMutableStringalloc]init];
[mStr appendString:info.money];
[mStr appendString:@"元"];
NSRange mRange = [info.desc rangeOfString:mStr];
NSMutableAttributedString * tttstring = [[NSMutableAttributedStringalloc] initWithString:info.desc];
UIColor *mColor = RGBCOLOR(224, 108, 0);
if (mRange.length != 0) {
[tttstring addAttribute:(NSString*)kCTForegroundColorAttributeName value:(id)[mColor CGColor] range:NSMakeRange(mRange.location, mRange.length - 1)];
}
NSString *sendTime = [NSDate dateStringWithTimeInterval:info.addtime];
self.timeLabel.text = sendTime;
[self.mTitleLabel setText:tttstring];
// self.mTitleLabel.linkAttributes = [self linkStyle];
// self.mTitleLabel.activeLinkAttributes = [self activeLinkStyle];
// [self.mTitleLabel addLinkToURL:[NSURL URLWithString:@"http://baidu.com"] withRange:NSMakeRange(2, 2)];
}
- (NSDictionary*)activeLinkStyle
{
NSMutableDictionary *mutableActiveLinkAttributes = [NSMutableDictionary dictionary];
[mutableActiveLinkAttributes setValue:[NSNumber numberWithBool:NO] forKey:(NSString *)kCTUnderlineStyleAttributeName];
[mutableActiveLinkAttributes setValue:(__bridge id)[[UIColor darkGrayColor] CGColor] forKey:(NSString *)kCTForegroundColorAttributeName];
[mutableActiveLinkAttributes setValue:(__bridge id)[[UIColor colorWithRed:0 green:0 blue:0 alpha:0.3f] CGColor] forKey:(NSString*)kTTTBackgroundFillColorAttributeName];
[mutableActiveLinkAttributes setValue:(__bridge id)[[UIColor colorWithRed:0 green:0 blue:0 alpha:0.3f] CGColor] forKey:(NSString*)kTTTBackgroundStrokeColorAttributeName];
[mutableActiveLinkAttributes setValue:[NSNumber numberWithFloat:1.0f] forKey:(NSString *)kTTTBackgroundLineWidthAttributeName];
[mutableActiveLinkAttributes setValue:[NSNumber numberWithFloat:2.0f] forKey:(NSString *)kTTTBackgroundCornerRadiusAttributeName];
return mutableActiveLinkAttributes;
}
- (NSDictionary*)linkStyle
{
NSMutableDictionary *mutableActiveLinkAttributes = [NSMutableDictionary dictionary];
[mutableActiveLinkAttributes setValue:[NSNumber numberWithBool:NO] forKey:(NSString *)kCTUnderlineStyleAttributeName];
[mutableActiveLinkAttributes setValue:(__bridge id)[kLabelTextColor CGColor] forKey:(NSString *)kCTForegroundColorAttributeName];
return mutableActiveLinkAttributes;
}
- (void)attributedLabel:(__unused TTTAttributedLabel *)label
didSelectLinkWithURL:(NSURL *)url {
[[UIApplicationsharedApplication]openURL:[NSURLURLWithString:@"http://baidu.com"]];
}
[self.mTitleLabelsetText:@""afterInheritingLabelAttributesAndConfiguringWithBlock:
^NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
[mutableAttributedString addAttribute:(NSString *)kCTForegroundColorAttributeName value:(id)[UIColor redColor] range:NSMakeRange(0, 3)];
return mutableAttributedString;//需要有返回值的,
}];
[tttstring addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue" size:15.0] range:NSMakeRange(0, tttstring.length)];
字体大小
-(void)tttDiliver
{
[self.diliveryLabel setText:@"本商品由美月淘发货提供售后服务"afterInheritingLabelAttributesAndConfiguringWithBlock:
^NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) {
[mutableAttributedString addAttribute:(NSString *)kCTForegroundColorAttributeName value:(id)[UIColor blackColor] range:NSMakeRange(4, 3)];
[mutableAttributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue" size:13.0] range:NSMakeRange(4, 3)];
return mutableAttributedString;
}];
}
以上是关于TTTAtibutedlabel again的主要内容,如果未能解决你的问题,请参考以下文章
getaddrinfo() 连续失败并出现 EAI_AGAIN
无法安装 appium - npm ERR!代码 EAI_AGAIN
博弈论 SG函数Fibonacci again and again
git提交代码报错Permission denied, please try again