我在 iOS 中的条形图应用程序有问题。我使用DSBarChart和滑块控件创建了一个条形图。我希望图表在更改滑块时动态更改。我怎么做?这是我到目前为止所做的示例代码。
- (void)sliderValueDidChange:(UISlider *)sender {
if((int)slider.value % 10 == 0) {
positionLabel.text = [NSString stringWithFormat:@"%d",(int)slider.value];
myValue = (int)slider.value;
}
NSDictionary *dict =[NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:10], @"0",
[NSNumber numberWithInt:20], @"1",
[NSNumber numberWithInt:15], @"2",
[NSNumber numberWithInt:25], @"3",
[NSNumber numberWithInt:30], @"4",
[NSNumber numberWithInt:20], @"5",
[NSNumber numberWithInt:15], @"6",
nil];
DSBarChart *chrt = [[DSBarChart alloc] initWithFrame:ChartView.bounds
color:[UIColor greenColor]
andDictionary:dict];
chrt.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
chrt.bounds = ChartView.bounds;
[ChartView addSubview:chrt];
}