您的位置:首页 > 移动开发 > IOS开发

iOS开发笔记--描边label

2016-03-14 17:51 495 查看
今天需求突然要求需要描边文字,在网上找了一下,发现挺简单的,自己封装了一个

- (void)drawTextInRect:(CGRect)rect {

CGSize shadowOffset = self.shadowOffset;
UIColor *textColor = self.textColor;

CGContextRef c = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(c, self.outlineWidth);
CGContextSetLineJoin(c, kCGLineJoinRound);

CGContextSetTextDrawingMode(c, kCGTextStroke);
self.textColor = self.outlineColor;
[super drawTextInRect:rect];

CGContextSetTextDrawingMode(c, kCGTextFill);
self.textColor = textColor;
self.shadowOffset = CGSizeMake(0, 0);
[super drawTextInRect:rect];

self.shadowOffset = shadowOffset;
}


下载地址:https://github.com/hopedark/ZZYLabel
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  ios ios开发