zoukankan      html  css  js  c++  java
  • 6控件(开关/滑块/进度条......)

    #pragma mark  1开关

    - (void)createSwitch{

        UISwitch *sw = [[UISwitch alloc]initWithFrame:CGRectMake(0, 70, 200, 40)];

        sw.tintColor = [UIColor redColor];

        sw.thumbTintColor = [UIColor orangeColor];

        [sw setOn:YES animated:YES];

        [sw addTarget: self action:@selector(swValueChanged:) forControlEvents:UIControlEventValueChanged];

        [self.view addSubview:sw];

        

    }

     

    - (void)swValueChanged:(UISwitch *)sw{

        NSLog(@"%d",sw.isOn);

        

    }

    #pragma mark 2分段

    - (void)createSegment{

    //    UISegmentedControl *seg = [[UISegmentedControl alloc]initWithFrame:CGRectMake(0, 120, 200, 40)];

        UISegmentedControl *seg = [[UISegmentedControl alloc]initWithItems:@[@"",@"",@""]];

        seg.frame = CGRectMake(0, 120, 200, 40);

        seg.selectedSegmentIndex = 1;

        [seg setTintColor:[UIColor redColor]];

        //字体大小

        [seg setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor greenColor],NSFontAttributeName :[UIFont systemFontOfSize:18]} forState:UIControlStateNormal];

        

        [seg addTarget:self action:@selector(segChanged:) forControlEvents:UIControlEventValueChanged];

        

        [self.view addSubview:seg];

        

        

    }

    - (void)segChanged:(UISegmentedControl *)seg{

        NSInteger index = seg.selectedSegmentIndex;

        if (index == 0) {

            NSLog(@"");

        }

        

        

    }

     

    #pragma mark 3步进器

    - (void)createStepper{

        UIStepper *st = [[UIStepper alloc]initWithFrame:CGRectMake(0, 180, 100, 40)];

        st.minimumValue = 1.0;

        st.maximumValue = 10.0;

        st.stepValue = 1//步进值

        st.wraps = YES//循环

        [st addTarget:self action:@selector(stChange:) forControlEvents:UIControlEventValueChanged];

        [self.view addSubview:st];

        

    }

    - (void)stChange:(UIStepper *)st{

        NSInteger *value = (NSInteger)st.value;

        NSLog(@"%ld",value);

        

    }

     

    #pragma mark 4滑块

    - (void)createSlider{

        UISlider *slider = [[UISlider alloc]initWithFrame:CGRectMake(0, 250, 200, 40)];

        slider.minimumValue = 0.0;

        slider.maximumValue = 100.0;

        slider.minimumTrackTintColor = [UIColor redColor];

        slider.maximumTrackTintColor = [UIColor greenColor];

        slider.thumbTintColor = [UIColor blackColor];

    //    [slider setThumbImage:[[UIImage alloc]init] forState:UIControlStateNormal];

        [slider addTarget:self action:@selector(sliderChanged:) forControlEvents:UIControlEventValueChanged ];

        [self.view addSubview:slider];

        

    }

    - (void)sliderChanged:(UISlider *)slider{

        

        NSLog(@"%lf",slider.value);

    }

     

     

    #pragma mark 5菊花加载

    - (void)createActivity{

        UIActivityIndicatorView *act = [[UIActivityIndicatorView alloc]initWithFrame:CGRectMake(0, 300, 100, 100)];

        act.color = [UIColor redColor];

        act.activityIndicatorViewStyle = UIActivityIndicatorViewStyleGray;

        act.hidesWhenStopped = YES;

        [act startAnimating];

        //[act stopAnimating];

        [self.view addSubview:act];

    }

    #pragma mark 6进度条 (配合定时器NSTimer使用)

    - (void)createProgress{

        UIProgressView *pV = [[UIProgressView alloc]initWithFrame:CGRectMake(0, 400, 200, 40)];

        pV.progress = 0.5//0-1

        pV.progressTintColor = [UIColor redColor];//已走过的轨道颜色

        pV.trackTintColor = [UIColor greenColor];

        [self.view addSubview:pV];

        

    }

  • 相关阅读:
    [HEOI2015]兔子与樱花
    Qt5——从零开始的Hello World教程(Qt Creator)
    qt利用QT designer构建第一个界面helloworld工程
    兆芯处理器的发展之路 从南北桥架构到开先KX-5000系列
    SPEC CPU 使用简介
    国产龙芯3A3000处理器评测:与英特尔差距明显
    测试
    【转载】ltp压力测试结果分析脚本
    H5开发基础之像素、分辨率、DPI、PPI
    【转载】分辨率和像素是什么关系?
  • 原文地址:https://www.cnblogs.com/daxueshan/p/5815612.html
Copyright © 2011-2022 走看看