- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor whiteColor];
1.创建UISlider.
UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(100, 300, 200, 100)];
slider.layer.borderWidth = 1;
slider.layer.cornerRadius = 10;
slider.backgroundColor = [UIColor greenColor];
[self.view addSubview:slider];
[slider release];
2.添加一个出发事件.
[slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
3.最大值和最小值.
slider.minimumValue = 0.5;
slider.maximumValue = 10;
}
4.实现事件.
- (void)sliderAction:(UISlider *)slider {
self.imageView.animationDuration = slider.value;
5.给对应的图片视图添加动画
[self.imageView startAnimating];
}
UI_UISlider
最新推荐文章于 2018-06-04 18:21:03 发布