Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

chhoda

macrumors 6502
Original poster
Oct 25, 2008
285
1
I am tryin to draw an indicator in a scrollview. i am trying with following code. It is not drawing anything at all. What could be the problem ?

- (void) drawScrollIndicator {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSetLineWidth(context, 10.0);
CGContextSetStrokeColorWithColor(context, [UIColor redColor].CGColor);
CGContextMoveToPoint(context, 0, 0);
CGContextAddLineToPoint(context, 0, self.frame.origin.y / 2);
CGContextStrokePath(context);
}

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
[self drawScrollIndicator];
}
 

PhoneyDeveloper

macrumors 68040
Sep 2, 2008
3,114
93
Two things come to mind.

You can't draw in a view except in response to a drawRect call. Implement drawRect for your view and call setNeedsDisplay as required to make your drawRect method be called.

What is the value of self.frame.origin.y / 2?

Are you aware that scroll views can already draw scroll indicators?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.