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

 

转载于:https://www.cnblogs.com/wangbinios/p/5509862.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值