Updating UIView subclass contents

Posted by Brett on Stack Overflow See other posts from Stack Overflow or by Brett
Published on 2010-06-14T15:04:55Z Indexed on 2010/06/16 2:52 UTC
Read the original article Hit count: 413

Filed under:
|
|
|
|

Hi;

I am trying to update a UIView subclass to draw individual pixels (rectangles) after calculating if they are in the mandelbrot set.

I am using the following code but am getting a blank screen:

//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];
}

Once I figure out how to display one pixel, I'd like to know how to go about updating the view by adding another pixel (once calculated). Once all the variables change, how do I keep the current view as is but add another pixel?

Thanks, Brett

© Stack Overflow or respective owner

Related posts about iphone

Related posts about xcode