zoukankan      html  css  js  c++  java
  • iOS富文本的使用

        NSString *name = nil;

        if (_payNumber == 1) { 

            name = [NSString stringWithFormat:@"向%@收款",nameStr];

        }else if (_payNumber == 2){  

        

            name = [NSString stringWithFormat:@"向%@付款",nameStr];

        }

        //富文本

        NSMutableAttributedString *abs = [[NSMutableAttributedString alloc] initWithString:name];

        shopNameLabel = [[UILabel alloc] init];

        shopNameLabel.font = [UIFont systemFontOfSize:17];

        shopNameLabel.textColor = [UIColor colorWithHexString:@"#666666"];

        //字体加粗

        [abs addAttribute:NSFontAttributeName value:[UIFont boldSystemFontOfSize:17.0] range:NSMakeRange(1, nameStr.length)];

        //颜色

        [abs addAttribute:NSForegroundColorAttributeName value:[UIColor colorWithHexString:@"#333333"] range:NSMakeRange(1, nameStr.length)];

        

        shopNameLabel.attributedText = abs;

        [shopNameLabel sizeToFit];     //取shopNameLabel.frame.size.width

        shopNameLabel.frame = CGRectMake((self.view.frame.size.width - shopNameLabel.frame.size.width)/ 2, shopLogoImg.frame.size.height + shopLogoImg.frame.origin.y + 15, shopNameLabel.frame.size.width, 25);

        shopNameLabel.textAlignment = NSTextAlignmentCenter;

        [shopInfoView addSubview:shopNameLabel];

  • 相关阅读:
    字符流中第一个不重复的字符 python实现
    当当网爬虫
    第六周---事后分析
    第四周的菜鸡互啄
    菜鸡互啄队——软件需求规格说明书
    菜鸡互啄队—— 团队合作
    Hadoop综合大作业
    分布式文件系统HDFS 练习
    安装Hadoop
    爬取全部的校园新闻
  • 原文地址:https://www.cnblogs.com/ios988/p/5946317.html
Copyright © 2011-2022 走看看