zoukankan      html  css  js  c++  java
  • 进击的UI---------------UISwitch(开关)

    {
    // UISwitch的使用
    UISwitch *oneSwitch = [[UISwitch alloc] initWithFrame:CGRectMake(20, 20, 0, 0)]; // 默认尺寸为79 * 27。
    oneSwitch.backgroundColor = [UIColor greenColor]; // 设置背景色
    oneSwitch.alpha = 1.0; // 设置透明度 范围在0.0-1.0之间 0.0是完全透明
    oneSwitch.onTintColor = [UIColor redColor]; // 在oneSwitch开启的状态显示的颜色 默认是blueColor
    oneSwitch.tintColor = [UIColor purpleColor]; // 设置关闭状态的颜色
    oneSwitch.thumbTintColor = [UIColor blueColor]; // 设置开关上左右滑动的小圆点的颜色
    // oneSwitch.on = YES; // // 设置初始状态 直接设置为on,你不回观察到它的变化
    [oneSwitch setOn:YES animated:YES]; // 设置初始状态,与上面的不同是当你看到这个控件的时候再开始设置为on,你会观察到他的变化
    oneSwitch.onImage = [UIImage imageNamed:@"min.png"]; // 打开状态显示的图片
    oneSwitch.offImage = [UIImage imageNamed:@"max.png"]; // 关闭状态下的图片
    [oneSwitch addTarget:self action:@selector(oneSwitchValueChanged:) forControlEvents:UIControlEventValueChanged]; // 添加事件监听器的方法
    // 添加到view并释放内存
    [self.view addSubview:oneSwitch];
    [oneSwitch release], oneSwitch = nil;
    #pragma mark - 实现UISwitch监听的方法
    - (void)oneSwitchValueChanged:(UISwitch *) sender {
        NSLog(@"%@", sender.isOn ? @"ON" : @"OFF");
    }
     
  • 相关阅读:
    IIS中安全证书更新
    mac权限相关命令
    Nlog配置Seq日志服务
    WPF Prism8.0中注册Nlog日志服务
    .NET MAUI Preview7 状态预览(8月)
    RPA剖析浏览器API(获取指定页面数据)
    .NET Core Worker Service
    .NET MAUI Preview6 状态预览(7月)
    Digicert GeoTrusy Cloud DV
    【Tomcat8】开启Https及挂载静态文件
  • 原文地址:https://www.cnblogs.com/sharkHZ/p/4984146.html
Copyright © 2011-2022 走看看