• ttt,


     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;

         }];

    }

  • 相关阅读:
    MVC @Url.Action 小示例
    Eclipse快捷键
    MVC视频下载/文件上传
    MySQL数据库备份/导出
    C#文件下载
    C#正则表达式匹配字符串中的数字
    常用的LINQ to SQL 用法
    C# 实现抓取网页内容(一)
    C# 繁体字和简体字之间的相互转换
    我到底会什么??
  • 原文地址:https://www.cnblogs.com/guligei/p/3535847.html
Copyright © 2020-2023  润新知