在自定义UIView中隐藏图形

| 我有自定义视图图表和该视图GraphViewController的视图控制器。 我正在实现简单的图形。 这是Chart.h的代码 #进口 @interface图表:UIView {     BOOL hideChart; } @property BOOL hideChart; -(void)drawAxesInContext:(CGContextRef)context; -(void)drawUserChartinContext:(CGContextRef)context; @结束 图表 -(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);     为(int i = 0; i 如您在屏幕截图上所见,我有uibutton \“ hide \”。我想通过按此按钮隐藏图形(而不是轴)。 在viewController中,我创建了ibaction -(IBAction)hideAndShow {     self.chart.hideChart = YES; } 在视图中您可以看到     如果(hideChart){     [[UIColor blackColor] setStroke];         [self setNeedsDisplay];         NSLog(@ \“隐藏\”);     } 但这是行不通的,您有什么主意我该怎么做? http://dl.dropbox.com/u/866144/Voila_Capture7.png     
已邀请:
我建议为hideChart添加一个自定义设置器,类似这样
- (void)setHideChart:(BOOL)isHidden {
    self.isHidden = isHidden;
}
    

要回复问题请先登录注册