zoukankan      html  css  js  c++  java
  • iOS文字描边

    当label用系统的字体干干巴巴的放在那会很难看,有时候我们需要给文字描边,让文字变得更漂亮

    想用文字想要有描边的话就让你的label继承自CTWBLabe可以了,而且文字颜色和描边颜色可以自定义.

    废话不多,直接上代码:

    //

    //  CTWBLabel.m

    //  SpeedPro

    //

    //  Created by WBapple on 16/5/17.

    //  Copyright © 2016年 Huawei. All rights reserved.

    //

    #import "CTWBLabel.h"

    @implementation CTWBLabel

    /**

     *  重写父类text方法

     *

     *  @param rect 文字描边

     */

    - (void)drawTextInRect:(CGRect)rect

    {

        //描边

        CGContextRef c = UIGraphicsGetCurrentContext ();

        CGContextSetLineWidth (c, 10);

        CGContextSetLineJoin (c, kCGLineJoinRound);

        CGContextSetTextDrawingMode (c, kCGTextStroke);

        //描边颜色

        self.textColor = [UIColor colorWithHexString:@"#29a5e5"];

        [super drawTextInRect:rect];

        //文字颜色

        self.textColor = [UIColor colorWithHexString:@"#ffb901"];

        CGContextSetTextDrawingMode (c, kCGTextFill);

        [super drawTextInRect:rect];

    }

    @end

  • 相关阅读:
    RA-Embedding-based Retrieval in Facebook Search
    RA-Recommending What Video to Watch Next: A Multitask Ranking System
    家事杂谈-2
    工作体会-3
    CCS
    CCS
    CCS
    CCS
    CCS
    CCS
  • 原文地址:https://www.cnblogs.com/wangbinios/p/5509862.html
Copyright © 2011-2022 走看看