美文网首页
设置字体颜色

设置字体颜色

作者: 袏扌戒指 | 来源:发表于2016-01-12 10:38 被阅读2976次

- (void)setButtonColor:(NSButton*)button andColor:(NSColor*)color {

if(color ==nil) {

color = [NSColor redColor];

}

NSFont *font = button.font;

NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:font,

NSFontAttributeName,

color,

NSForegroundColorAttributeName,

nil];

NSAttributedString* attributedString = [[NSAttributedString alloc] initWithString:[button title] attributes:attrs];

[button setAttributedTitle:attributedString];

}

相关文章

  • UIWebView利用js设置字体大小

    1、UIWebView设置字体大小,颜色,字体:1、UIWebView设置字体大小,颜色,字体: UIWebVie...

  • iOS控件之UILabel

    属性 设置内容 设置字体颜色 设置对齐方式 设置字体大小 背景颜色 换行模式 设置最小收缩比例 设置行数 设置文字...

  • Swfit:控件属性备注

    设置文字 设置字体颜色 设置字体大小 另一种方式设置

  • swift UILabel用法详解

    创建 设置背景颜色 设置读取文本,默认为nil 设置字体颜色,默认为黑色 设置文字大小,默认17 设置字体居中 设...

  • swift设置文字字体和颜色

    设置文字字体 设置文字颜色

  • html、css学习笔记(六)

    颜色设置:有字体颜色(color)、背景颜色(background-color)、边框颜色(border)等,设置...

  • Swift 中Tabbar 的设置

    1: TabbarItem 图片大小 2: 修改图片和字体的颜色 (1)设置图片和字体的选中颜色 (2)只设置字体...

  • Android studio 3.1 基础设置

    窗口字体设置 控制台字体设置 Logcat颜色设置 快速文档设置 代码字体设置 代码背景设置(护眼模式) 自动导包...

  • CSS字体(font)

    字体 字体的颜色 color 用来设置字体颜色 字体的大小 font-size 字体的大小 和font-size相...

  • 设置字体颜色

    - (void)setButtonColor:(NSButton*)button andColor:(NSColo...

网友评论

      本文标题:设置字体颜色

      本文链接:https://www.haomeiwen.com/subject/vsxckttx.html