iOS中怎么利用UILabel实现文字添加描边功能

今天就跟大家聊聊有关iOS中怎么利用UILabel实现文字添加描边功能,可能很多人都不太了解,为了让大家更加了解,小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。

继承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;}

看完上述内容,你们对iOS中怎么利用UILabel实现文字添加描边功能有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注行业资讯频道,感谢大家的支持。