• 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);
    }
    

      

  • 相关阅读:
    (Ubuntu)下载及安装Genymosion模拟器并配置Android Studio
    ROS CMakeLists中target_link_libraries相对路径设置
    VS_C#快捷键
    一行代码实现各产品访问统计???[原创]
    PyCharm下载安装
    装饰模式(Decorator)
    Python之格式化输出
    python入门
    servlet--http接口简单的创建及调用
    Storm-jdbc-2讲 高级API及Trident
  • 原文地址:https://www.cnblogs.com/sqdhy-zq/p/4788884.html
Copyright © 2020-2023  润新知