我想創建一個範圍滑塊。但是當我在同一位置分配2個滑塊時,只有1個工作。我發現了一些外部API來創建Slider。有沒有什麼辦法在iOS中以編程方式創建範圍滑塊。如何在iOS中以編程方式創建範圍滑塊?
這裏是我的代碼..
CGRect frame = CGRectMake(20, 330, 300, 60);
slider1 = [[UISlider alloc] initWithFrame:frame];
[slider1 addTarget:self action:@selector(sliderActionMin:) forControlEvents:UIControlEventValueChanged];
[slider1 setBackgroundColor:[UIColor clearColor]];
slider1.minimumValue = 0.0;
slider1.maximumValue = 55.0;
slider1.continuous = YES;
slider1.value= 16
slider1.contentMode=UIViewContentModeScaleToFill;
[self.view addSubview:slider1];
slider2 = [[UISlider alloc] initWithFrame:frame];
[slider2 addTarget:self action:@selector(sliderActionMin:) forControlEvents:UIControlEventValueChanged];
[slider2 setBackgroundColor:[UIColor clearColor]];
slider2.minimumValue = 0.0;
slider2.maximumValue = 55.0;
slider2.continuous = YES;
slider2.contentMode=UIViewContentModeScaleToFill;
slider2.value=[SingletonClass sharedSingleton].minAge;
[self.view addSubview:slider2];
爲什麼在同一位置分配2個滑塊? – Bannings
這意味着兩個滑塊在一個位置,1是最小值,第二個是最大值..你明白嗎? –
@ Bannings-因爲我想展示年齡範圍。像16到22 –