After UIGraphicsGetCurrentContext() call CGContextClearRect(context,rect)
Edit: Good, got it.
The custom view in the line should have the following:
- (id)initWithFrame:(CGRect)frame { if (self = [super initWithFrame:frame]) { [self setBackgroundColor:[UIColor clearColor]]; } return self; } - (void)drawRect:(CGRect)rect { CGContextRef context = UIGraphicsGetCurrentContext(); CGContextClearRect(context, rect); CGContextSetStrokeColorWithColor(context, [UIColor whiteColor].CGColor); CGContextSetLineWidth(context, 5.0); CGContextMoveToPoint(context, 100.0,0.0); CGContextAddLineToPoint(context,100.0, 100.0); CGContextStrokePath(context); }
My test used this as a very simple UIViewController:
- (void)viewDidLoad { [super viewDidLoad]; UIImageView *v = [[UIImageView alloc] initWithFrame:self.view.bounds]; [v setBackgroundColor:[UIColor redColor]]; [self.view addSubview:v]; TopView *t = [[TopView alloc] initWithFrame:self.view.bounds]; [self.view addSubview:t]; [v release]; [t release]; }
David Kanarek Jan 24 '10 at 1:45 2010-01-24 01:45
source share