UISegmentedControl(分页控制器) AND UISlider(滑块控制器)
2014-04-01 15:04
309 查看
- (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 - 分段控制器 //initWithItems:可以添加图片或者字符串 UISegmentedControl * segment = [[UISegmentedControl alloc]initWithItems:@[@"statr",@"stop",@"HMT"]]; segment.frame = CGRectMake(10, 20, 300, 40); // 分了几段 NSLog(@"%lu",segment.numberOfSegments); // 选中时,是一直呈现高亮状态(NO)还是瞬间的高亮(YES) segment.momentary = YES; [segment addTarget:self action:@selector(onClickSegmentedControl:) forControlEvents:UIControlEventValueChanged]; // 把下标为2的区段,设置为不可点击 [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{ // selectedSegmentIndex 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]; // Dispose of any resources that can be recreated. } @end
相关文章推荐
- UISegmentedControl(分页控制器) AND UISlider(滑块控制器)
- UISegmentedControl(分页控制器) AND UISlider(滑块控制器)
- iOS分页控制器
- 用Android中的ActionBar来实现分页Title栏滑块效果
- 用Android中的ActionBar来实现分页Title栏滑块效果
- salesforce使用Apex控制器和VF实现自定义服务器端分页项目实战(自定义分页)
- android 分页Title栏滑块效果--ActionBar(模拟网易 腾讯等动态效果)
- 分页 视图和控制器
- Ajax--滑块的滑动来分页
- 分页控制器
- iOS不得姐项目--推荐关注模块(一个控制器控制两个tableView),数据重复请求的问题,分页数据的加载,上拉下拉刷新(MJRefresh)
- 第二十篇:滚动视图UIScrollView ,分页控制器UIPageControl 定时器 NSTimer
- IOS分页控制器
- iOS UIPageControl(分页控制器) 用法总结
- 轮播图和UIPageControl(分页控制器)、NSTimer(定时器)
- jquery 3D分页翻转滑块
- mvc.net分页查询案例——控制器(HomeController.cs)
- IOS UIPageControl(分页控制器) 用法总结
- 用Android中的ActionBar来实现分页Title栏滑块效果
- IOS分页控制器 - UIPageControl