• UISwitch | UIStepper


    UISwitch 开关空间

    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        
        UISwitch *switchC = [[UISwitch alloc] initWithFrame:CGRectMake(150, 100, 50, 50)];
        switchC.onTintColor = [UIColor redColor]; // 打开后的颜色
        switchC.tintColor = [UIColor greenColor];  // 周围圈的颜色
        switchC.thumbTintColor = [UIColor yellowColor]; // 开关颜色
        switchC.on = YES; // 初始默认是关上的NO
        [switchC setOn:NO animated:YES];
        [switchC addTarget:self action:@selector(doTap:) forControlEvents:(UIControlEventValueChanged)];
        
        [self.view addSubview:switchC];
        [switchC release];
    }
    
    - (void)doTap:(UISwitch *)swithC
    {
        if (swithC.on) {
            self.view.backgroundColor = [UIColor grayColor];
        }
        else
        {
            self.view.backgroundColor = [UIColor magentaColor];
        }
    }
    

      打开开关     关上开关

    UIStepper

    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
           
        UIStepper *step = [[UIStepper alloc] initWithFrame:CGRectMake(150, 200, 50, 50)];
        step.minimumValue = 0;
        step.maximumValue = 9;
        step.stepValue = 1; // 每次变化的数值
        step.value = 5; // 当前的数值
        
        [step addTarget:self action:@selector(doStep:) forControlEvents:(UIControlEventValueChanged)];
        
        [self.view addSubview:step];
        
    }
    
    - (void)doStep:(UIStepper *)step
    {
        NSLog(@"%f, %f", step.stepValue, step.value);
    }
    

      

  • 相关阅读:
    Linux命令行操作基础练习
    Linux基础系统优化
    神奇的二维码(觉得有点儿意思,转了~)
    django 中的cookie和session
    django 中间件操作
    django orm操作
    django 视图
    django 路由
    django(2) 模板
    django 模板(1)
  • 原文地址:https://www.cnblogs.com/sqdhy-zq/p/4788884.html
Copyright © 2020-2023  润新知