• 设置UIButton文字大小颜色不同


    _loginBtn = [[UIButton alloc]initWithFrame:CGRectMake(iconX, CGRectGetMaxY(passwordBGView.frame)+25, 280, 35)];
    [_loginBtn setTitle:@"进入游戏
    START GAME" forState:UIControlStateNormal];
    _loginBtn.titleLabel.font = [UIFont systemFontOfSize:16];
             
    NSMutableAttributedString *attString = [[NSMutableAttributedString alloc] initWithString:_loginBtn.titleLabel.text];
    [attString addAttribute:(NSString*)NSForegroundColorAttributeName value:[UIColor whiteColor] range:[_loginBtn.titleLabel.text rangeOfString:_loginBtn.titleLabel.text]];
    [attString addAttribute:(NSString*)NSForegroundColorAttributeName value:[UIColor whiteColor] range:[_loginBtn.titleLabel.text rangeOfString:@"START GAME"]];
    [attString addAttribute:(NSString*)NSFontAttributeName value:[UIFont systemFontOfSize:10] range:[_loginBtn.titleLabel.text rangeOfString:@"START GAME"]];
    [_loginBtn setAttributedTitle:attString forState:UIControlStateNormal];
             
    _loginBtn.titleLabel.textAlignment = NSTextAlignmentCenter;
    _loginBtn.titleLabel.lineBreakMode = NSLineBreakByCharWrapping;
    

     

  • 相关阅读:
    swift基础语法(05- 可选值)
    swift基础语法(03- 运算符)
    swift基础语法(04- 元组)
    swift基础语法(02-基本数据类型)
    tableView的全屏穿透效果的实现
    ScrollView属性解析
    TableView的重要性
    SQLite操作
    openFileOutput的几种文件模式
    保存文件到SDcard
  • 原文地址:https://www.cnblogs.com/damiao/p/4394563.html
Copyright © 2020-2023  润新知