我正在尝试以编程方式向 UIView 添加一个高度可变的垂直 UISlider。这是我目前所拥有的
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, slider 就不会出现。任何帮助将不胜感激!
最佳答案
你可以试试这个 并制作 slider 值方法
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 - 当我尝试以编程方式向 UIView 添加 Slider 时,如果宽度太高,它不会出现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9264859/