JKLLockScreenNumber.m 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. //
  2. // JKLLockScreenNumber.m
  3. //
  4. #import "JKLLockScreenNumber.h"
  5. static const CGFloat LSNContextSetLineWidth = 0.8f;
  6. @implementation JKLLockScreenNumber
  7. - (void)setHighlighted:(BOOL)highlighted {
  8. if (super.highlighted != highlighted) {
  9. super.highlighted = highlighted;
  10. [self setNeedsDisplay];
  11. }
  12. }
  13. // Only override drawRect: if you perform custom drawing.
  14. // An empty implementation adversely affects performance during animation.
  15. - (void)drawRect:(CGRect)rect {
  16. // Drawing code
  17. CGFloat height = CGRectGetHeight(rect);
  18. CGRect inset = CGRectInset(CGRectMake(0, 0, height, height), 1, 1);
  19. CGContextRef context = UIGraphicsGetCurrentContext();
  20. CGColorRef colorRef = [self tintColor].CGColor;
  21. UIControlState state = [self state];
  22. CGContextSetLineWidth(context, LSNContextSetLineWidth);
  23. if (state == UIControlStateHighlighted) {
  24. CGContextSetFillColorWithColor(context, colorRef);
  25. CGContextFillEllipseInRect (context, inset);
  26. CGContextFillPath(context);
  27. }
  28. else {
  29. CGContextSetStrokeColorWithColor(context, colorRef);
  30. CGContextAddEllipseInRect(context, inset);
  31. CGContextStrokePath(context);
  32. }
  33. }
  34. @end