label的文字描邊
阿新 • • 發佈:2019-02-15
@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