[iOS] 文字描边方法

来源:互联网 发布:画漫画的软件 编辑:程序博客网 时间:2024/06/16 08:07

继承UILabel然后重写一下方法

- (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://stackoverflow.com/questions/1103148/how-do-i-make-uilabel-display-outlined-text#

0 0
原创粉丝点击