LineView.m 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // LineView.m
  3. // Apex Mobile
  4. //
  5. // Created by Ray on 14-3-21.
  6. // Copyright (c) 2014年 United Software Applications, Inc. All rights reserved.
  7. //
  8. #import "LineView.h"
  9. @implementation LineView
  10. - (id)initWithFrame:(CGRect)frame
  11. {
  12. self = [super initWithFrame:frame];
  13. if (self) {
  14. // Initialization code
  15. }
  16. return self;
  17. }
  18. - (void)drawRect:(CGRect)rect
  19. {
  20. CGContextRef context = UIGraphicsGetCurrentContext();
  21. // CGRect frame = self.contentView.frame;
  22. // CGContextAddRect(context,frame);
  23. if(self.linewidth==0)
  24. self.linewidth=0.5;
  25. CGContextSetLineWidth(context, 0.5);
  26. if(self.linecolor==nil)
  27. self.linecolor = [UIColor lightGrayColor];
  28. CGContextSetStrokeColorWithColor(context, [self.linecolor CGColor]/*[[UIColor colorWithRed:0.10 green:0.68 blue:0.94 alpha:0.7] CGColor]*/);
  29. // CGRect selrect = self.bounds;
  30. CGContextMoveToPoint(context, self.bounds.size.width*0.4, self.bounds.origin.y);
  31. CGContextAddLineToPoint(context, self.bounds.size.width*0.4, self.bounds.size.height);
  32. // CGContextStrokePath(context);
  33. CGContextMoveToPoint(context, self.linewidth/2, self.bounds.origin.y);
  34. CGContextAddLineToPoint(context, self.linewidth/2, self.bounds.size.height);
  35. CGContextMoveToPoint(context, self.bounds.size.width-self.linewidth/2, self.bounds.origin.y);
  36. CGContextAddLineToPoint(context, self.bounds.size.width-self.linewidth/2, self.bounds.size.height);
  37. CGContextStrokePath(context);
  38. [super drawRect:rect];
  39. }
  40. @end