- //继承UILabel以后重载drawTextInRect
- - (void)drawTextInRect:(CGRect)rect {
- CGSize shadowOffset = self.shadowOffset;
- UIColor *textColor = self.textColor;
- CGContextRef c = UIGraphicsGetCurrentContext();
- CGContextSetLineWidth(c, 1);
- CGContextSetLineJoin(c, kCGLineJoinRound);
- CGContextSetTextDrawingMode(c, kCGTextStroke);
- self.textColor = [UIColor whiteColor];
- [super drawTextInRect:rect];
- CGContextSetTextDrawingMode(c, kCGTextFill);
- self.textColor = textColor;
- self.shadowOffset = CGSizeMake(0, 0);
- [super drawTextInRect:rect];
- self.shadowOffset = shadowOffset;
- }
- //该片段来自于http://www.codesnippet.cn/detail/191220138153.html
来源: http://www.codesnippet.cn/detail/191220138153.html