gpt4 book ai didi

iphone - 当我尝试以编程方式向 UIView 添加 Slider 时,如果宽度太高,它不会出现

转载 作者:行者123 更新时间:2023-11-29 13:40:40 25 4
gpt4 key购买 nike

我正在尝试以编程方式向 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/

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