BGStrokeLabel.m 674 B

1234567891011121314151617181920212223242526272829
  1. //
  2. // BGStrokeLabel.m
  3. // BuguLive
  4. //
  5. // Created by xfg on 2017/7/11.
  6. // Copyright © 2017年 xfg. All rights reserved.
  7. //
  8. #import "BGStrokeLabel.h"
  9. @implementation BGStrokeLabel
  10. - (void)drawRect:(CGRect)rect
  11. {
  12. CGContextRef c = UIGraphicsGetCurrentContext();
  13. // 设置描边宽度
  14. CGContextSetLineWidth(c, 1);
  15. CGContextSetLineJoin(c, kCGLineJoinRound);
  16. CGContextSetTextDrawingMode(c, kCGTextStroke);
  17. // 描边颜色
  18. self.textColor = [UIColor redColor];
  19. [super drawTextInRect:rect];
  20. // 文本颜色
  21. self.textColor = [UIColor yellowColor];
  22. CGContextSetTextDrawingMode(c, kCGTextFill);
  23. [super drawTextInRect:rect];
  24. }
  25. @end