Hide graph in custom UIView
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开发者_JS百科 : 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; iAs 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
I suggest adding a custom setter for hideChart, something like this
- (void)setHideChart:(BOOL)isHidden {
self.isHidden = isHidden;
}
精彩评论