我有自定义视图图表和视图控制器的视图GraphViewController。 我正在实现简单的图表。
这是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; 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"); }
但它不起作用,你有什么想法我怎么能做到这一点? http://dl.dropbox.com/u/866144/Voila_Capture7.png
答案 0 :(得分:0)
我建议为hideChart添加一个自定义setter,类似这样的
- (void)setHideChart:(BOOL)isHidden {
self.isHidden = isHidden;
}