1
votes

I have custom view Chart and view controller for that view GraphViewController. I'm implementing simple graph.

Here is code for Chart.h

#import 


@interface Chart : UIView {
    BOOL hideChart;
}
@property BOOL hideChart;
- (void) drawAxesInContext:(CGContextRef)context;
- (void) drawUserChartinContext:(CGContextRef)context;
@end

Chart.m


- (void)drawRect:(CGRect)rect
{
    CGContextRef ctxt = UIGraphicsGetCurrentContext();
    [self drawAxesInContext:ctxt]; 
    [self drawUserChartinContext:ctxt];
}

- (void) drawAxesInContext:(CGContextRef)context {
    CGContextTranslateCTM(context, nullX, nullY);
    CGContextScaleCTM(context, 1.0, -1.0);
    CGContextSetLineWidth(context, 3);
    CGContextBeginPath(context);   

    for (int i=0; i 

As you can see on screenshot I have uibutton "hide". I want to hide graph (not axes) by pressing this button. In viewController I created ibaction

- (IBAction) hideAndShow {
    self.chart.hideChart = YES;
}

and in view u can see

if (hideChart) { [[UIColor blackColor] setStroke]; [self setNeedsDisplay]; NSLog(@"hide"); }

But it not works, do you any ideas how can I make this? http://dl.dropbox.com/u/866144/Voila_Capture7.png

1

1 Answers

0
votes

I suggest adding a custom setter for hideChart, something like this

- (void)setHideChart:(BOOL)isHidden {
    self.isHidden = isHidden;
}