ScannerControllerView.m 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. //
  2. // ScannerView.m
  3. // CodeScanner
  4. //
  5. // Created by Ray on 14-7-24.
  6. // Copyright (c) 2014年 Shinobi Controls. All rights reserved.
  7. //
  8. #import "ScannerControllerView.h"
  9. @implementation ScannerControllerView
  10. - (id)initWithFrame:(CGRect)frame
  11. {
  12. self = [super initWithFrame:frame];
  13. if (self) {
  14. // Initialization code
  15. }
  16. return self;
  17. }
  18. // Only override drawRect: if you perform custom drawing.
  19. // An empty implementation adversely affects performance during animation.
  20. - (void)drawRect:(CGRect)rect
  21. {
  22. CGContextRef con = UIGraphicsGetCurrentContext();
  23. CGContextSetFillColorWithColor(con, [[UIColor colorWithRed:0 green:0 blue:0 alpha:0.5] CGColor]);
  24. CGContextFillRect(con, rect);
  25. //CGRect frame =CGRectMake(100,100,300,300);
  26. CGContextClearRect(con, self.highLightRect);
  27. // Drawing code
  28. if(!self.auto_style)
  29. {
  30. // CGRect frame = self.contentView.frame;
  31. // // CGContextAddRect(context,frame);
  32. CGContextSetLineWidth(con, 1.0);
  33. //
  34. CGContextSetStrokeColorWithColor(con, [[UIColor redColor] CGColor]);
  35. //
  36. // CGRect selrect = self.highLightRect;
  37. CGContextMoveToPoint(con, self.highLightRect.origin.x, self.highLightRect.origin.y+ self.highLightRect.size.height/2.0);
  38. CGContextAddLineToPoint(con, self.highLightRect.origin.x+ self.highLightRect.size.width, self.highLightRect.origin.y+self.highLightRect.size.height/2.0);
  39. //
  40. CGContextStrokePath(con);
  41. }
  42. [super drawRect:rect];
  43. }
  44. @end