gpt4 book ai didi

ios - 在自定义 UIView 中隐藏图表

转载 作者:行者123 更新时间:2023-11-28 17:46:31 24 4
gpt4 key购买 nike

我有自定义 View 图表和该 View GraphViewController 的 View Controller 。我正在实现简单的图表。

这是 Chart.h 的代码

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

图表.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;}

在 View 中你可以看到

如果(隐藏图表){ [[UIColor blackColor] setStroke]; [自行设置NeedsDisplay]; NSLog(@"隐藏"); }

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

最佳答案

我建议为 hideChart 添加一个自定义 setter ,像这样

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

关于ios - 在自定义 UIView 中隐藏图表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5663774/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com