zoukankan      html  css  js  c++  java
  • UIPageControl,UISlider

     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
  • 相关阅读:
    CS224n, lec 10, NMT & Seq2Seq Attn
    CS231n笔记 Lecture 11, Detection and Segmentation
    CS231n笔记 Lecture 10, Recurrent Neural Networks
    CS231n笔记 Lecture 9, CNN Architectures
    CS231n笔记 Lecture 8, Deep Learning Software
    CS231n笔记 Lecture 7, Training Neural Networks, Part 2
    pytorch坑点排雷
    Sorry, Ubuntu 17.10 has experienced an internal error
    VSCode配置python插件
    tmux配置与使用
  • 原文地址:https://www.cnblogs.com/DevinSMR/p/5167645.html
Copyright © 2011-2022 走看看