// // BGStrokeLabel.m // BuguLive // // Created by xfg on 2017/7/11. // Copyright © 2017年 xfg. All rights reserved. // #import "BGStrokeLabel.h" @implementation BGStrokeLabel - (void)drawRect:(CGRect)rect { CGContextRef c = UIGraphicsGetCurrentContext(); // 设置描边宽度 CGContextSetLineWidth(c, 1); CGContextSetLineJoin(c, kCGLineJoinRound); CGContextSetTextDrawingMode(c, kCGTextStroke); // 描边颜色 self.textColor = [UIColor redColor]; [super drawTextInRect:rect]; // 文本颜色 self.textColor = [UIColor yellowColor]; CGContextSetTextDrawingMode(c, kCGTextFill); [super drawTextInRect:rect]; } @end