drawRect is not refreshing the screen

Posted by coure06 on Stack Overflow See other posts from Stack Overflow or by coure06
Published on 2010-06-17T07:13:37Z Indexed on 2010/06/17 7:23 UTC
Read the original article Hit count: 266

Filed under:
|

I have this code in my drawRect method

float aValue = .0167f;
float fValue = 20;
for(int i=1; i<=6; i++)
        {

            CGContextSelectFont(context, "Arial", fValue, kCGEncodingMacRoman);
            CGContextSetCharacterSpacing(context, 0);
            CGContextSetTextDrawingMode(context, kCGTextFill);

            NSString *hString = [[NSString alloc] initWithFormat:@"%i",i];


            CGContextSetRGBFillColor(context, 1, 1, 1, aValue);
            CGContextShowTextAtPoint(context, i*25, i*16, [hString UTF8String], [hString length]);
            aValue += 0.167;
            fValue += 1;

        }

I am calling a method using NSTimer like this

staticTimer = [NSTimer scheduledTimerWithTimeInterval:1.0 target:self selector:@selector(refreshUIView) userInfo:nil repeats:YES];

here is the refreshUIView

-(void)refreshUIView
{
    [self setNeedsDisplay];
}

Problem is that drawRect is not clearing the screen, its just over writing what have been written last time on screen.

© Stack Overflow or respective owner

Related posts about objective-c

Related posts about iphone-sdk