-
- (void)viewDidLoad
-
{
-
[super viewDidLoad];
-
-
UIImageView * animatedImageView = [[UIImageView alloc]initWithFrame:CGRectMake(60, 80, 200, 300)];
-
animatedImageView.backgroundColor = [UIColor redColor];
-
animatedImageView.tag = 100;
-
[self.view addSubview:animatedImageView];
-
[animatedImageView release];
-
-
NSMutableArray * arrayImages = [NSMutableArray array];
-
for (int i = 1; i < 8; i++) {
-
-
[arrayImages addObject:[UIImage imageNamed:[NSString stringWithFormat:@"huoju_%i.tiff",i]]];
-
-
}
-
-
animatedImageView.animationImages = arrayImages;
-
-
#pragma mark - 分段控制器
-
-
UISegmentedControl * segment = [[UISegmentedControl alloc]initWithItems:@[@"statr",@"stop",@"HMT"]];
-
segment.frame = CGRectMake(10, 20, 300, 40);
-
-
NSLog(@"%lu",segment.numberOfSegments);
-
-
segment.momentary = YES;
-
[segment addTarget:self action:@selector(onClickSegmentedControl:) forControlEvents:UIControlEventValueChanged];
-
-
[self.view addSubview:segment];
-
[segment release];
-
-
-
-
UISlider * slider = [[UISlider alloc]initWithFrame:CGRectMake(10, 500, 300, 40)];
-
slider.maximumValue = 3;
-
slider.minimumValue = 0.1;
-
NSLog(@"%f",slider.value);
-
[self.view addSubview:slider];
-
[slider release];
-
[slider addTarget:self action:@selector(changeSliderValue:) forControlEvents:UIControlEventValueChanged];
-
-
}
-
-
-
- (void)onClickSegmentedControl:(UISegmentedControl *)segmented{
-
-
-
if (segmented.selectedSegmentIndex == 0) {
-
-
[((UIImageView *)[self.view viewWithTag:100]) startAnimating];
-
-
} else {
-
-
[((UIImageView *)[self.view viewWithTag:100]) stopAnimating];
-
-
}
-
}
-
-
- (void)changeSliderValue:(UISlider *)sLider{
-
-
-
((UIImageView *)[self.view viewWithTag:100]).animationDuration = sLider.value;
-
[((UIImageView *)[self.view viewWithTag:100]) startAnimating];
-
}
-
-
-
- (void)didReceiveMemoryWarning
-
{
-
[super didReceiveMemoryWarning];
-
-
}
UISegmentedControl(分页控制器) AND UISlider(滑块控制器),布布扣,bubuko.com
UISegmentedControl(分页控制器) AND UISlider(滑块控制器)
原文:http://blog.csdn.net/zuoyou1314/article/details/38089271