【问题标题】:Hide graph in custom UIView在自定义 UIView 中隐藏图形
【发布时间】:2011-08-05 13:07:35
【问题描述】:

我有自定义视图图表和该视图 GraphViewController 的视图控制器。 我正在实现简单的图表。

这是 Chart.h 的代码

#进口 @interface 图表:UIView { BOOL 隐藏图表; } @property BOOL 隐藏图表; -(无效)drawAxesInContext:(CGContextRef)上下文; -(无效)drawUserChartinContext:(CGContextRef)上下文; @结尾

图表.m

- (void)drawRect:(CGRect)rect { CGContextRef ctxt = UIGraphicsGetCurrentContext(); [self drawAxesInContext:ctxt]; [self drawUserChartinContext:ctxt]; } -(无效)drawAxesInContext:(CGContextRef)上下文{ CGContextTranslateCTM(context, nullX, nullY); CGContextScaleCTM(上下文, 1.0, -1.0); CGContextSetLineWidth(上下文, 3); CGContextBeginPath(上下文); 对于 (int i=0; 我

正如您在屏幕截图中看到的那样,我有 uibutton“隐藏”。我想通过按此按钮隐藏图形(不是轴)。 在 viewController 我创建了 ibaction

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

在视图中你可以看到

如果(隐藏图表){ [[UIColor blackColor] setStroke]; [自我设置需求显示]; NSLog(@"隐藏"); }

但它不起作用,你知道我该怎么做吗? http://dl.dropbox.com/u/866144/Voila_Capture7.png

【问题讨论】:

    标签: ios uiview uiviewcontroller uibutton


    【解决方案1】:

    我建议为 hideChart 添加一个自定义设置器,类似这样

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

    【讨论】:

      猜你喜欢
      • 2016-05-25
      • 1970-01-01
      • 2017-05-14
      • 2019-12-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-31
      • 1970-01-01
      相关资源
      最近更新 更多