我试图以编程方式将垂直UISlider添加到具有可变高度的UIView中。这就是我到目前为止
int fullSize = [myBottle.barBottem intValue] - [myBottle.barTop intValue];
CGRect frame = CGRectMake(200, 150,fullSize, 23);
slider = [[UISlider alloc] initWithFrame:frame];
[slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged];
[slider setBackgroundColor:[UIColor clearColor]];
slider.minimumValue = 0.0;
slider.maximumValue = fullSize;
slider.continuous = YES;
slider.transform = CGAffineTransformMakeRotation(M_PI * -
0.5);;
[self.view addSubview:slider];
我的问题是,每当fullSize> 320时,滑块都不会出现。任何帮助将不胜感激!
最佳答案
你可以试试这个
并制作滑块值方法
UISlider *loslider=[[UISlider alloc]initWithFrame:CGRectMake(60, 80, 200, 30)];
[loslider addTarget:self action:@selector(slider_Action:) forControlEvents:UIControlEventValueChanged];
[loslider setMaximumValue:100.0];
[loslider setMinimumValue:0.0];
[loslider setValue:0.0];
[self.view addSubview:loslider];
然后-(void)slider:Action
关于iphone - 当我尝试以编程方式将UISlider添加到UIView时,如果宽度过大则不会出现,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/9264859/