zoukankan      html  css  js  c++  java
  • UISwitcher

     1 //同步属性和成员变量
     2 @synthesize mySwitch = _mySwitch;
     3 
     4 - (void)viewDidLoad {
     5     [super viewDidLoad];
     6 
     7     _mySwitch = [[UISwitch alloc]init];
     8     
     9     //宽高两个属性参数没有用,苹果自己定好了宽高
    10     _mySwitch.frame = CGRectMake(100, 100, 40, 40);
    11     
    12    // _mySwitch.on = YES;
    13     
    14     //set方式
    15     //[_mySwitch setOn:YES];
    16     
    17     [_mySwitch setOn:YES animated:YES];
    18     
    19     //设置开启状态时风格
    20     //[_mySwitch setOnTintColor:[UIColor blueColor]];
    21     
    22     //圆钮
    23     [_mySwitch setThumbTintColor:[UIColor redColor]];
    24     //整体
    25     [_mySwitch setTintColor:[UIColor blackColor]];
    26     
    27     [self.view addSubview:_mySwitch];
    28     
    29     
    30     [_mySwitch addTarget:self  action:@selector(swchanged:) forControlEvents:UIControlEventValueChanged];
    31     
    32     
    33 }
    34 
    35 -(void) swchanged:(UISwitch*) sw
    36 {
    37     if(sw.on)
    38     {
    39            NSLog(@"Sw open");
    40     }
    41     else
    42     {
    43         NSLog(@"Sw closed");
    44     }
    45     
    46  
    47 }
    1 @interface ViewController : UIViewController
    2 {
    3     //定义一个开关控件
    4     UISwitch* _mySwitch ;
    5 }
    6 
    7 @property (retain,nonatomic) UISwitch* mySwitch;
  • 相关阅读:
    python3--shelve 模块
    python3--常用模块
    python3 时间复杂度
    Python3 正则表达式
    python--冒泡排序
    python3--正则表达式
    python3--算法基础:二维数组转90度
    python3--算法基础:二分查找/折半查找
    python3--递归
    dedecms单独调用指定文章
  • 原文地址:https://www.cnblogs.com/vector11248/p/7580447.html
Copyright © 2011-2022 走看看