LBRectangularView.m 953 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. //
  2. // LBRectangularView.m
  3. // Calendar module
  4. //
  5. // Created by king on 1511-4-308.
  6. // Copyright © 2015年 luqinbin. All rights reserved.
  7. //
  8. #import "LBRectangularView.h"
  9. @implementation LBRectangularView
  10. - (instancetype)init
  11. {
  12. self = [super init];
  13. if(!self){
  14. return nil;
  15. }
  16. self.backgroundColor = [UIColor clearColor];
  17. self.color = [UIColor whiteColor];
  18. return self;
  19. }
  20. - (void)drawRect:(CGRect)rect
  21. {
  22. CGContextRef ctx = UIGraphicsGetCurrentContext();
  23. CGContextAddRect(ctx, CGRectMake(0, 0, self.frame.size.width, self.frame.size.height));
  24. CGContextSetFillColorWithColor(ctx, [self.backgroundColor CGColor]);
  25. CGContextSetStrokeColorWithColor(ctx, [self.color CGColor]);
  26. CGContextSetFillColorWithColor(ctx, [self.color CGColor]);
  27. CGContextFillPath(ctx);
  28. }
  29. - (void)setColor:(UIColor *)color
  30. {
  31. self->_color = color;
  32. [self setNeedsDisplay];
  33. }
  34. @end