码迷,mamicode.com
首页 > 其他好文 > 详细

UIPageControl,UISlider

时间:2016-01-29 00:07:19      阅读:190      评论:0      收藏:0      [点我收藏+]

标签:

 1 #import "ViewController.h"
 2 
 3 @interface ViewController ()
 4 
 5 @end
 6 
 7 @implementation ViewController
 8 
 9 - (void)viewDidLoad {
10     [super viewDidLoad];
11     self.view.backgroundColor = [UIColor whiteColor];
12     
13 #pragma mark--------UISlider---------------
14     UISlider *slider = [[UISlider alloc] initWithFrame:CGRectMake(100, 550, 300, 50)];
15     slider.minimumValue = 0;
16     slider.maximumValue = 2.0;
17     //slider.backgroundColor = [UIColor redColor];
18      [slider addTarget:self action:@selector(sliderAction:) forControlEvents:UIControlEventValueChanged];
19     [self.view addSubview:slider];
20    
21    
22 #pragma mark--------UIPageControll--------
23     UIPageControl *page = [[UIPageControl alloc] initWithFrame:CGRectMake(100, 600, 100, 30)];
24     //指定页面个数
25     page.numberOfPages = 4;
26     //指定默认值
27     //从0开始计算
28     page.currentPage = 1;
29     //添加事件
30     [page addTarget:self action:@selector(pageAction:) forControlEvents:UIControlEventTouchUpInside];
31     page.backgroundColor = [UIColor redColor];
32     [self.view addSubview:page];
33     
34     NSMutableArray *array = [NSMutableArray array];
35     for (int i = 1 ; i < 8; i++) {
36         NSString *name = [NSString stringWithFormat:@"huoju_%d.tiff",i];
37         UIImage *image = [UIImage imageNamed:name];
38         [array addObject:image];
39     }
40     UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(100, 200, 200, 200)];
41     imageView.center = self.view.center;
42     imageView.animationDuration = 1;
43     imageView.animationImages = array;
44     imageView.animationRepeatCount = 0;
45     [imageView startAnimating];
46     imageView.tag = 1000;
47     [self.view addSubview:imageView];
48     
49     
50 }
51 #pragma mark ----UIPageControl响应事件
52 -(void)pageAction:(id)page
53 {
54     NSLog(@"我是UIPageControl");
55 }
56 #pragma mark-------UISlider 响应事件
57 -(void)sliderAction:(UISlider *)slider;
58 {
59    
60     UIImageView *imageView =(UIImageView *) [self.view viewWithTag:1000];
61     imageView.animationDuration = 2 - slider.value;
62     imageView.animationRepeatCount = 0;
63     [imageView startAnimating];
64     NSLog(@"UISlider当前值:%f", imageView.animationDuration);
65 }
66 
67 - (void)didReceiveMemoryWarning {
68     [super didReceiveMemoryWarning];
69     // Dispose of any resources that can be recreated.
70 }
71 
72 @end

 

UIPageControl,UISlider

标签:

原文地址:http://www.cnblogs.com/DevinSMR/p/5167645.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!