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

  • 相关阅读:
    [poj 1741]Tree 点分治
    [bzoj 3251]树上三角形
    [bzoj 3687]简单题 bitset的运用
    HDU [P5015] 233 Matrix
    POJ 3233
    洛谷 [P3629] 巡逻
    POJ 2728 Desert King
    洛谷 [P2886] 牛继电器Cow Relays
    POJ 1734 Sightseeing trip
    洛谷 [P3008] 道路与航线
  • 原文地址:https://www.cnblogs.com/wangbinios/p/5509862.html
Copyright © 2011-2022 走看看