zoukankan      html  css  js  c++  java
  • 在一个UILabel的文字采用不同的字体样式和字体大小

    //标题:红包大厅

            UILabel* tmp_title=[[UILabel alloc] initWithFrame:CGRectMake(0 , 5, max_View.frame.size.width, 24)];

            tmp_title.text=@"进入红包大厅";

            [tmp_title setFont:[UIFont boldSystemFontOfSize:22]];

            [tmp_title setTextColor:[UIColor redColor]];

            [tmp_title setTextAlignment:NSTextAlignmentCenter];

            [self addSubview:tmp_title];

            

            //------------

            NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:@"进入红包大厅"];

            

            NSRange range1=NSMakeRange(0, 6);

            [str addAttribute:NSForegroundColorAttributeName value:[UIColor redColor] range:range1];

            [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Arial-BoldItalicMT" size:10.0] range:NSMakeRange(0, 1)];

            [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"HelveticaNeue-Bold" size:14.0] range:NSMakeRange(1, 1)];

            

            [str addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"Courier-BoldOblique" size:18.0] range:NSMakeRange(2, 1)];

            

             tmp_title.attributedText=str;

    //显示结果如下图:

    这是在同一个UILabel 中显示不同的字体大小,还是比较实用的

  • 相关阅读:
    DP问题之最长非降子序列
    CentOS 6.8 编译安装MySQL5.5.32
    [Linux] killall 、kill 、pkill 命令详解
    编写登陆接口
    python学习day01
    python购物车程序
    ERROR:Attempting to call cordova.exec() before 'deviceready'
    BSF脚本引擎‘改变’Bean
    Solr安装配置
    amchart配置备忘
  • 原文地址:https://www.cnblogs.com/sugeladi/p/5087937.html
Copyright © 2011-2022 走看看