1. 程式人生 > >label的文字描邊

label的文字描邊

@interface DrawLabel : UILabel

@end

@implementation DrawLabel

- (void)drawTextInRect:(CGRect)rect {

CGSize shadowOffset = self.shadowOffset;

UIColor *textColor = self.textColor;

CGContextRef c = UIGraphicsGetCurrentContext();

CGContextSetLineWidth(c, 5);

CGContextSetLineJoin(c, kCGLineJoinRound

);

CGContextSetTextDrawingMode(c, kCGTextStroke);

self.textColor = [UIColorwhiteColor];

    [superdrawTextInRect:rect];

CGContextSetTextDrawingMode(c, kCGTextFill);

self.textColor = textColor;

self.shadowOffset = CGSizeMake(0, 0);

    [superdrawTextInRect:rect];

self.shadowOffset = shadowOffset;

}

@end