2010-06-14 9 views
0

J'essaie de mettre à jour une sous-classe UIView pour dessiner des pixels individuels (rectangles) après avoir calculé s'ils sont dans l'ensemble mandelbrot.Mise à jour du contenu de la sous-classe UIView

J'utilise le code suivant, mais je reçois un écran vide:

//drawingView.h 

... 

-(void)drawRect:(CGRect)rect{ 

    CGContextRef context = UIGraphicsGetCurrentContext(); 

    CGContextSetRGBFillColor(context, r, g, b, 1); 
    CGContextSetRGBStrokeColor(context, r, g, b, 1); 

    CGRect arect = CGRectMake(x,y,1,1); 


    CGContextFillRect(context, arect); 

} 
... 

//viewController.m 
... 
- (void)viewDidLoad { 
    [drawingView setX:10]; 
    [drawingView setY:10]; 
    [drawingView setR:0.0]; 
    [drawingView setG:0.0]; 
    [drawingView setB:0.0]; 
    [super viewDidLoad]; 
    [drawingView setNeedsDisplay]; 
} 

Une fois que je figure sur la façon d'afficher un pixel, je voudrais savoir comment aller à mettre à jour la vue en ajoutant un autre pixel (une fois calculé). Une fois que toutes les variables ont changé, comment conserver la vue actuelle telle quelle mais ajouter un autre pixel?

Merci, Brett

Répondre

0
CGContextMoveToPoint(context, xcoord, ycoord); 
CGContextAddLineToPoint(context, xcoord, ycoord); 
CGContextStrokePath(context); 
Questions connexes