It can be hard to see when the label is dry with the font of the system, and sometimes we need to stroke the text to make it more beautiful.
If you want to use text to have a stroke, let your label inherit from Ctwblabe, and the text color and stroke color can be customized.
Not much nonsense, directly on the code:
//
ctwblabel.m
Speedpro
//
Created by Wbapple on 16/5/17.
COPYRIGHT©2016 year Huawei. All rights reserved.
//
#import "CTWBLabel.h"
@implementation Ctwblabel
/**
* Overriding parent class text method
*
* @param rect text strokes
*/
-(void) Drawtextinrect: (cgrect) rect
{
Strokes
Cgcontextref C = Uigraphicsgetcurrentcontext ();
Cgcontextsetlinewidth (c, 10);
Cgcontextsetlinejoin (c, Kcglinejoinround);
Cgcontextsettextdrawingmode (c, Kcgtextstroke);
Stroke color
Self.textcolor = [Uicolor colorwithhexstring:@ "#29a5e5"];
[Super Drawtextinrect:rect];
Text color
Self.textcolor = [Uicolor colorwithhexstring:@ "#ffb901"];
Cgcontextsettextdrawingmode (c, Kcgtextfill);
[Super Drawtextinrect:rect];
}
@end
iOS text stroke