zoukankan      html  css  js  c++  java
  • UISwitch控件

    用处:开关空间,用于处理两种状态

    -(void)viewDidLoad

    {

      [super viewDidLoad];

      CGRect frame = CGRectMake(20,20,0,0);

      self.switch = [[UISwitch alloc]initWithFrame:frame];

      //设置初始状态

     [self.switch setOn:YES];

    //底色颜色

    self.switch.tintColor = [UIColor redColor];

    //开启底色颜色

    self.switch.ontintColor = [UIColor brownColor];

    //滑块颜色

    self.switch.thumbtintColor = [UIColor greenColor];

    //添加值改变事件方法

    [self.switch addTarget:self action:@selector(change:) forControlEvents:UIControlEventValueChanged];

    [self.view addSubView:self.switch];

    }

    -(IBAction) change:(id)sender

    {

      UISwitch* switch = (UISwitch*)sender;

      if(switch.on)

          {NSLog(@"set on");}

      else

          {NSLog(@"set off");}

    }

  • 相关阅读:
    Map-HashMap
    Collection(List & Set)
    Redis五种数据类型详解
    Redis基本数据结构详解
    分布式Session管理
    一致性算法
    Zookeeper
    分布式锁
    线程池原理解析
    疑点难点1.1
  • 原文地址:https://www.cnblogs.com/AngryCooder/p/3894774.html
Copyright © 2011-2022 走看看