NSMutableAttributedString字体颜色等属性

<span class="preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#import "ViewController.h"</span>
<span class="preprocessor" style="color: rgb(153, 153, 153); font-weight: bold;">#import <CoreText/CoreText.h></span>

@<span class="keyword" style="font-weight: bold;">interface</span> ViewController ()

@end

@implementation ViewController

- (<span class="keyword" style="font-weight: bold;">void</span>)viewDidLoad
{
    [super viewDidLoad];
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//学习内容</span>
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">/*
     1.控件 UIView UILabel UITextField UITextView UIButton
     2.字体、大小、单位、颜色
     */</span>
    UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(<span class="number" style="color: rgb(0, 153, 153);">10</span>, <span class="number" style="color: rgb(0, 153, 153);">30</span>, <span class="number" style="color: rgb(0, 153, 153);">300</span>, <span class="number" style="color: rgb(0, 153, 153);">260</span>)];
    label.text = <span class="string" style="color: rgb(221, 17, 68);">@"Label Text Content, This is a text label things attribute"</span>;<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//默认为空</span>
    label.font = [UIFont systemFontOfSize:<span class="number" style="color: rgb(0, 153, 153);">17</span>];<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//默认使用系统的17</span>
    label.textColor = [UIColor orangeColor];<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//默认使用文本黑色</span>
    label.shadowColor = [UIColor lightGrayColor];<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//默认没有阴影</span>
    label.shadowOffset = CGSizeMake(<span class="number" style="color: rgb(0, 153, 153);">1</span>,<span class="number" style="color: rgb(0, 153, 153);">0</span>);<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//默认是一个向上的阴影(0,-1)</span>
    label.textAlignment = NSTextAlignmentCenter;<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//默认是左对齐</span>
    label.lineBreakMode = NSLineBreakByTruncatingTail;<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//段落样式,默认是最后截断尾巴,用...代替</span>
    
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//富文本的基本数据类型,属性字符串。以此为基础,如果这个设置了相应的属性,则会忽略上面设置的属性,默认为空</span>
    NSString *<span class="keyword" style="font-weight: bold;">string</span> = label.text;
    <span class="keyword" style="font-weight: bold;">const</span> CGFloat fontSize = <span class="number" style="color: rgb(0, 153, 153);">16.0</span>;
    NSMutableAttributedString *attrString = [[NSMutableAttributedString alloc] initWithString:<span class="keyword" style="font-weight: bold;">string</span>];
    NSUInteger length = [<span class="keyword" style="font-weight: bold;">string</span> length];
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//设置字体</span>
    UIFont *baseFont = [UIFont systemFontOfSize:fontSize];
    [attrString addAttribute:NSFontAttributeName <span class="keyword" style="font-weight: bold;">value</span>:baseFont range:NSMakeRange(<span class="number" style="color: rgb(0, 153, 153);">0</span>, length)];<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//设置所有的字体</span>
    UIFont *boldFont = [UIFont boldSystemFontOfSize:fontSize];
    [attrString addAttribute:NSFontAttributeName <span class="keyword" style="font-weight: bold;">value</span>:boldFont range:[<span class="keyword" style="font-weight: bold;">string</span> rangeOfString:<span class="string" style="color: rgb(221, 17, 68);">@"Text"</span>]];<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//设置Text这四个字母的字体为粗体</span>
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//设置倾斜,需要导入coreText</span>
    UIFont *italicFont = GetVariationOfFontWithTrait(baseFont,
                                                     kCTFontTraitItalic);
    [attrString addAttribute:NSFontAttributeName <span class="keyword" style="font-weight: bold;">value</span>:italicFont
                       range:[<span class="keyword" style="font-weight: bold;">string</span> rangeOfString:<span class="string" style="color: rgb(221, 17, 68);">@"Label"</span>]];
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">// 设置颜色</span>
    UIColor *color = [UIColor redColor];
    [attrString addAttribute:NSForegroundColorAttributeName
                       <span class="keyword" style="font-weight: bold;">value</span>:color
                       range:[<span class="keyword" style="font-weight: bold;">string</span> rangeOfString:<span class="string" style="color: rgb(221, 17, 68);">@"Content"</span>]];
    [attrString addAttribute:NSBackgroundColorAttributeName <span class="keyword" style="font-weight: bold;">value</span>:[UIColor blueColor] range:[<span class="keyword" style="font-weight: bold;">string</span> rangeOfString:<span class="string" style="color: rgb(221, 17, 68);">@"ent"</span>]];
    
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//可以对这些属性设置值</span>
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//字体名称有以下:</span>
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//    label.font = [UIFont fontWithName:@"Arial-BoldItalicMT" size:24];</span>
    [attrString addAttribute:NSFontAttributeName <span class="keyword" style="font-weight: bold;">value</span>:[UIFont fontWithName:<span class="string" style="color: rgb(221, 17, 68);">@"Verdana-BoldItalic"</span> size:<span class="number" style="color: rgb(0, 153, 153);">18</span>] range:[<span class="keyword" style="font-weight: bold;">string</span> rangeOfString:<span class="string" style="color: rgb(221, 17, 68);">@"Label"</span>]];
    label.numberOfLines = <span class="number" style="color: rgb(0, 153, 153);">2</span>;
    NSMutableParagraphStyle *
    style = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
    style.lineSpacing = <span class="number" style="color: rgb(0, 153, 153);">10</span>;<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//增加行高</span>
    style.headIndent = <span class="number" style="color: rgb(0, 153, 153);">10</span>;<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//头部缩进,相当于左padding</span>
    style.tailIndent = -<span class="number" style="color: rgb(0, 153, 153);">10</span>;<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//相当于右padding</span>
    style.lineHeightMultiple = <span class="number" style="color: rgb(0, 153, 153);">1.5</span>;<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//行间距是多少倍</span>
    style.alignment = NSTextAlignmentLeft;<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//对齐方式</span>
    style.firstLineHeadIndent = <span class="number" style="color: rgb(0, 153, 153);">20</span>;<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//首行头缩进</span>
    style.paragraphSpacing = <span class="number" style="color: rgb(0, 153, 153);">10</span>;<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//段落后面的间距</span>
    style.paragraphSpacingBefore = <span class="number" style="color: rgb(0, 153, 153);">20</span>;<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//段落之前的间距</span>
    [attrString addAttribute:NSParagraphStyleAttributeName <span class="keyword" style="font-weight: bold;">value</span>:style range:NSMakeRange(<span class="number" style="color: rgb(0, 153, 153);">0</span>, length)];
    
    [attrString addAttribute:NSKernAttributeName <span class="keyword" style="font-weight: bold;">value</span>:@<span class="number" style="color: rgb(0, 153, 153);">2</span> range:NSMakeRange(<span class="number" style="color: rgb(0, 153, 153);">0</span>, length)];<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//字符间距 2pt</span>
    [attrString addAttribute:NSStrokeColorAttributeName <span class="keyword" style="font-weight: bold;">value</span>:[UIColor blueColor] range:[<span class="keyword" style="font-weight: bold;">string</span> rangeOfString:<span class="string" style="color: rgb(221, 17, 68);">@"is"</span>]];<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//设置文字描边颜色,需要和NSStrokeWidthAttributeName设置描边宽度,这样就能使文字空心</span>
    [attrString addAttribute:NSStrokeWidthAttributeName <span class="keyword" style="font-weight: bold;">value</span>:@<span class="number" style="color: rgb(0, 153, 153);">2</span> range:[<span class="keyword" style="font-weight: bold;">string</span> rangeOfString:<span class="string" style="color: rgb(221, 17, 68);">@"is"</span>]];<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//空心字,文字边框描述</span>
    [attrString addAttribute:NSUnderlineStyleAttributeName <span class="keyword" style="font-weight: bold;">value</span>:@(NSUnderlineStyleSingle) range:[<span class="keyword" style="font-weight: bold;">string</span> rangeOfString:<span class="string" style="color: rgb(221, 17, 68);">@"text"</span>]];<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//下划线</span>
    [attrString addAttribute:NSUnderlineStyleAttributeName <span class="keyword" style="font-weight: bold;">value</span>:@(NSUnderlineStyleThick) range:[<span class="keyword" style="font-weight: bold;">string</span> rangeOfString:<span class="string" style="color: rgb(221, 17, 68);">@"label"</span>]];<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//厚的下划线</span>
    [attrString addAttribute:NSStrikethroughStyleAttributeName <span class="keyword" style="font-weight: bold;">value</span>:@(NSUnderlinePatternSolid | NSUnderlineStyleSingle) range:[<span class="keyword" style="font-weight: bold;">string</span> rangeOfString:<span class="string" style="color: rgb(221, 17, 68);">@"things"</span>]];<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//删除线</span>
    [attrString addAttribute:NSStrikethroughColorAttributeName <span class="keyword" style="font-weight: bold;">value</span>:[UIColor blueColor] range:[<span class="keyword" style="font-weight: bold;">string</span> rangeOfString:<span class="string" style="color: rgb(221, 17, 68);">@"things"</span>]];<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//删除线蓝色</span>
   label.attributedText = attrString;
    
    label.highlightedTextColor = [UIColor redColor];<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//设置文本高亮显示颜色,与highlighted一起使用。</span>
    label.highlighted = NO; <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//高亮状态是否打开</span>
    label.enabled = YES;<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//设置文字内容是否可变</span>
    label.userInteractionEnabled = YES;<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//设置标签是否忽略或移除用户交互。默认为NO</span>
    label.baselineAdjustment = UIBaselineAdjustmentNone;<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//如果adjustsFontSizeToFitWidth属性设置为YES,这个属性就来控制文本基线的行为。</span>
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//    UIBaselineAdjustmentAlignBaselines=0,默认,文本最上端与中线对齐。</span>
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//    UIBaselineAdjustmentAlignCenters,   文本中线与label中线对齐。</span>
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//    UIBaselineAdjustmentNone,  文本最低端与label中线对齐。;</span>
    [self.view addSubview:label];
    
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">/*
     字体名如下:
     Font Family: American Typewriter
     Font: AmericanTypewriter
     Font: AmericanTypewriter-Bold
     
     Font Family: AppleGothic
     Font: AppleGothic
     
     Font Family: Arial
     Font: ArialMT
     Font: Arial-BoldMT
     Font: Arial-BoldItalicMT
     Font: Arial-ItalicMT
     
     Font Family: Arial Rounded MT Bold
     Font: ArialRoundedMTBold
     
     Font Family: Arial Unicode MS
     Font: ArialUnicodeMS
     
     Font Family: Courier
     Font: Courier
     Font: Courier-BoldOblique
     Font: Courier-Oblique
     Font: Courier-Bold
     
     Font Family: Courier New
     Font: CourierNewPS-BoldMT
     Font: CourierNewPS-ItalicMT
     Font: CourierNewPS-BoldItalicMT
     Font: CourierNewPSMT
     
     Font Family: DB LCD Temp
     Font: DBLCDTempBlack
     
     Font Family: Georgia
     Font: Georgia-Bold
     Font: Georgia
     Font: Georgia-BoldItalic
     Font: Georgia-Italic
     
     Font Family: Helvetica
     Font: Helvetica-Oblique
     Font: Helvetica-BoldOblique
     Font: Helvetica
     Font: Helvetica-Bold
     
     Font Family: Helvetica Neue
     Font: HelveticaNeue
     Font: HelveticaNeue-Bold
     
     Font Family: Hiragino Kaku Gothic **** W3
     Font: HiraKakuProN-W3
     
     Font Family: Hiragino Kaku Gothic **** W6
     Font: HiraKakuProN-W6
     
     Font Family: Marker Felt
     Font: MarkerFelt-Thin
     
     Font Family: STHeiti J
     Font: STHeitiJ-Medium
     Font: STHeitiJ-Light
     
     Font Family: STHeiti K
     Font: STHeitiK-Medium
     Font: STHeitiK-Light
     
     Font Family: STHeiti SC
     Font: STHeitiSC-Medium
     Font: STHeitiSC-Light
     
     Font Family: STHeiti TC
     Font: STHeitiTC-Light
     Font: STHeitiTC-Medium
     
     Font Family: Times New Roman
     Font: TimesNewRomanPSMT
     Font: TimesNewRomanPS-BoldMT
     Font: TimesNewRomanPS-BoldItalicMT
     Font: TimesNewRomanPS-ItalicMT
     
     Font Family: Trebuchet MS
     Font: TrebuchetMS-Italic
     Font: TrebuchetMS
     Font: Trebuchet-BoldItalic
     Font: TrebuchetMS-Bold
     
     Font Family: Verdana
     Font: Verdana-Bold
     Font: Verdana-BoldItalic
     Font: Verdana
     Font: Verdana-Italic
     
     Font Family: Zapfino
     Font: Zapfino
     */</span>
    
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//文本对齐方式</span>
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">/* Values for NSTextAlignment */</span>
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">/*
    NSTextAlignmentLeft 左对齐
    NSTextAlignmentCenter 剧中对齐
    NSTextAlignmentRight 右对齐
    NSTextAlignmentJustified 两端对齐
    NSTextAlignmentNatural 根据显示的文字特性对齐
    */</span>
    
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//段落样式</span>
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">/*
    lineSpacing;                         来增加行距
    paragraphSpacing;
    alignment;                           对齐
    firstLineHeadIndent;                 段落开始的缩排像素
    headIndent;                          可调整全部文字的缩排距离,可当作左边 padding 使用
    tailIndent;                          可调整文字尾端的缩排距离。需要注意的是,这里指定的值可以当作文字显示的宽、而也可当作右边 padding 使用,依据输入的正负值而定:
    lineBreakMode;
    minimumLineHeight;
    maximumLineHeight;        而针对不同的字型与字号,我们可以透过指定最大与最小行距(maximumLineHeight 与 minimumLineHeight)来避免过高或过窄的状况发生。
    baseWritingDirection;
    lineHeightMultiple;                  想要调整行距,可以透过搭配使用 lineHeightMultiple 更改行距倍数
    paragraphSpacingBefore; 而若是文章内容有分段落的话,也可以透过指定段落结尾距离(paragraphSpacing)以及段落开头距离(paragraphSpacingBefore):
    hyphenationFactor;
        @property(readwrite,copy,NS_NONATOMIC_IOSONLY) NSArray *tabStops NS_AVAILABLE_IOS(7_0);
        @property(readwrite,NS_NONATOMIC_IOSONLY) CGFloat defaultTabInterval NS_AVAILABLE_IOS(7_0);
     */</span>
    
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">/* Predefined character attributes for text. If the key is not in the dictionary, then use the default values as described below.  //预定义的文本属性值,如果键不是一个字典,那么使用默认的值作为以下描述
     NSFontAttributeName 字体 默认是Helvetica 12号
     NSParagraphStyleAttributeName 段落样式
     */</span>
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">/*
    UIKIT_EXTERN NSString *const  NS_AVAILABLE_IOS(6_0);      // NSParagraphStyle, default defaultParagraphStyle
    UIKIT_EXTERN NSString *const NSForegroundColorAttributeName NS_AVAILABLE_IOS(6_0);     // UIColor, default blackColor
    UIKIT_EXTERN NSString *const NSBackgroundColorAttributeName NS_AVAILABLE_IOS(6_0);     // UIColor, default nil: no background
    UIKIT_EXTERN NSString *const NSLigatureAttributeName NS_AVAILABLE_IOS(6_0);            // NSNumber containing integer, default 1: default ligatures, 0: no ligatures
    UIKIT_EXTERN NSString *const NSKernAttributeName NS_AVAILABLE_IOS(6_0);                // NSNumber containing floating point value, in points; amount to modify default kerning. 0 means kerning is disabled. (note: values other than nil and 0 are unsupported on iOS)
    UIKIT_EXTERN NSString *const NSStrikethroughStyleAttributeName NS_AVAILABLE_IOS(6_0);  // NSNumber containing integer, default 0: no strikethrough
    UIKIT_EXTERN NSString *const NSUnderlineStyleAttributeName NS_AVAILABLE_IOS(6_0);      // NSNumber containing integer, default 0: no underline
    UIKIT_EXTERN NSString *const NSStrokeColorAttributeName NS_AVAILABLE_IOS(6_0);         // UIColor, default nil: same as foreground color
    UIKIT_EXTERN NSString *const NSStrokeWidthAttributeName NS_AVAILABLE_IOS(6_0);         // NSNumber containing floating point value, in percent of font point size, default 0: no stroke; positive for stroke alone, negative for stroke and fill (a typical value for outlined text would be 3.0)
    UIKIT_EXTERN NSString *const NSShadowAttributeName NS_AVAILABLE_IOS(6_0);              // NSShadow, default nil: no shadow
    UIKIT_EXTERN NSString *const NSTextEffectAttributeName NS_AVAILABLE_IOS(7_0);          // NSString, default nil: no text effect

    UIKIT_EXTERN NSString *const NSAttachmentAttributeName NS_AVAILABLE_IOS(7_0);          // NSTextAttachment, default nil
    UIKIT_EXTERN NSString *const NSLinkAttributeName NS_AVAILABLE_IOS(7_0);                // NSURL (preferred) or NSString
    UIKIT_EXTERN NSString *const NSBaselineOffsetAttributeName NS_AVAILABLE_IOS(7_0);      // NSNumber containing floating point value, in points; offset from baseline, default 0
    UIKIT_EXTERN NSString *const NSUnderlineColorAttributeName NS_AVAILABLE_IOS(7_0);      // UIColor, default nil: same as foreground color
    UIKIT_EXTERN NSString *const NSStrikethroughColorAttributeName NS_AVAILABLE_IOS(7_0);  // UIColor, default nil: same as foreground color
    UIKIT_EXTERN NSString *const NSObliquenessAttributeName NS_AVAILABLE_IOS(7_0);         // NSNumber containing floating point value; skew to be applied to glyphs, default 0: no skew
    UIKIT_EXTERN NSString *const NSExpansionAttributeName NS_AVAILABLE_IOS(7_0);           // NSNumber containing floating point value; log of expansion factor to be applied to glyphs, default 0: no expansion

    UIKIT_EXTERN NSString *const NSWritingDirectionAttributeName NS_AVAILABLE_IOS(7_0);    // NSArray of NSNumbers representing the nested levels of writing direction overrides as defined by Unicode LRE, RLE, LRO, and RLO characters.  The control characters can be obtained by masking NSWritingDirection and NSTextWritingDirection values.  LRE: NSWritingDirectionLeftToRight|NSTextWritingDirectionEmbedding, RLE: NSWritingDirectionRightToLeft|NSTextWritingDirectionEmbedding, LRO: NSWritingDirectionLeftToRight|NSTextWritingDirectionOverride, RLO: NSWritingDirectionRightToLeft|NSTextWritingDirectionOverride,

    UIKIT_EXTERN NSString *const NSVerticalGlyphFormAttributeName NS_AVAILABLE_IOS(6_0);   // An NSNumber containing an integer value.  0 means horizontal text.  1 indicates vertical text.  If not specified, it could follow higher-level vertical orientation settings.  Currently on iOS, it's always horizontal.  The behavior for any other value is undefined.
     */</span>
    
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">// NSParagraphStyle  段落样式</span>
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//    typedef NS_ENUM(NSInteger, NSLineBreakMode) {		/* What to do with long lines */ //对于长内容或多行内容的处理方式</span>
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//        NSLineBreakByWordWrapping = 0,     	/* Wrap at word boundaries, default */   //按包含单词为界限截断</span>
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//        NSLineBreakByCharWrapping,		/* Wrap at character boundaries */           //按字符为界限截断</span>
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//        NSLineBreakByClipping,		/* Simply clip */                                //简单的修剪</span>
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//        NSLineBreakByTruncatingHead,	/* Truncate at head of line: "...wxyz" */        //截断头部</span>
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//        NSLineBreakByTruncatingTail,	/* Truncate at tail of line: "abcd..." */        //截断尾巴</span>
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//        NSLineBreakByTruncatingMiddle	/* Truncate middle of line:  "ab...yz" */        //截断中间</span>
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//    } NS_ENUM_AVAILABLE_IOS(6_0);</span>
}
<span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">//获取斜体</span>
UIFont * GetVariationOfFontWithTrait(UIFont *baseFont,
                                     CTFontSymbolicTraits trait) {
    CGFloat fontSize = [baseFont pointSize];
    CFStringRef
    baseFontName = (__bridge CFStringRef)[baseFont fontName];
    CTFontRef baseCTFont = CTFontCreateWithName(baseFontName,
                                                fontSize, NULL);
    CTFontRef ctFont =
    CTFontCreateCopyWithSymbolicTraits(baseCTFont, <span class="number" style="color: rgb(0, 153, 153);">0</span>, NULL,
                                       trait, trait);
    NSString *variantFontName =
    CFBridgingRelease(CTFontCopyName(ctFont,
                                     kCTFontPostScriptNameKey));

    UIFont *variantFont = [UIFont fontWithName:variantFontName
                                          size:fontSize];
    CFRelease(ctFont);
    CFRelease(baseCTFont);
    <span class="keyword" style="font-weight: bold;">return</span> variantFont;
};


- (<span class="keyword" style="font-weight: bold;">void</span>)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    <span class="comment" style="color: rgb(153, 153, 136); font-style: italic;">// Dispose of any resources that can be recreated.</span>
}

@end
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值