UISwitch控件的作用是提供一个开关给用户,用户可以选择打开或者关闭。

UISwitch的基本属性包括:

1.onTintColor:打开状态下的背景颜色

2.thumbTintColor:滑块的颜色

UISwitch可以通过UIControlEventValueChanged来达到监听开关状态的变化。

ps:onTintColor没有对应的offTintColor属性,你可以通过设置父控件背景色的方式(backgroundColor)来控制关闭状态下的背景色。

- (void) createUI {
self.switcher = [[UISwitch alloc] initWithFrame:CGRectMake(100, 100, 100, 40)];
self.switcher.onTintColor = [UIColor orangeColor];
self.switcher.thumbTintColor = [UIColor redColor];
self.view.backgroundColor = [UIColor blueColor]; [self.view addSubview:self.switcher];
[self.switcher addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventValueChanged];
}

  

UISwitch控件的使用的更多相关文章

  1. IOS开发之XCode学习011:UISwitch控件

    此文学习来源为:http://study.163.com/course/introduction/1002858003.htm 此工程文件实现功能:  1.定义UIswitch控件,添加UIswitc ...

  2. IOS UISwitch 控件

    转自:http://my.oschina.net/wolx/blog/396680 一 UISwitch 简介 二 UISwitch 创建 三设置选中状态 四 添加监听 五 测试代码 5.1 代码 5 ...

  3. iOS开关按钮UISwitch控件

    开关按钮UISwitch 在ViewController.h里面 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 #import <UIKit/UIKit ...

  4. IOS UISwitch控件的基本使用

    * UISwitch继承自UIControl,因此也能像UIButton一样监听一些事件,比如状态改变事件* UISwitch可以通过拖线监听状态改变* UISwitch可以通过addTarget:. ...

  5. iOS-UI-UI控件概述

    以下列举一些在开发中可能用得上的UI控件: IBAction和IBOutlet,UIView 1 @interface ViewController : UIViewController 2 3 @p ...

  6. iOS-UI控件概述

    IBAction和IBOutlet,UIView 1 @interface ViewController : UIViewController 2 3 @property(nonatomic, wea ...

  7. iOS UIView控件的常用属性和方法的总结

    一 UIVIew 常见属性1.frame 位置和尺寸(以父控件的左上角为原点(0,0))2.center 中点 (以父控件的左上角为原点(0,0))3.bounds 位置和尺寸(以自己的左上角为原点 ...

  8. iOS基本UI控件总结

    包括以下几类: //继承自NSObject:(暂列为控件) UIColor *_color;    //颜色 UIImage *_image;    //图像 //继承自UIView:只能相应手势UI ...

  9. swift系统学习控件篇:UIbutton+UIlabel+UITextField+UISwitch+UISlider

    工作之余,学习下swift大法.把自己的学习过程分享一下.当中的布局很乱,就表在意这些细节了.直接上代码: UIButton+UILabel // // ViewController.swift // ...

随机推荐

  1. Java队列工具类(程序仅供练习)

    public class QueueUtils<T> { public int defaultSize; public Object[] data; public int front = ...

  2. NGUI Camera's raycast hit through the UI Layer issue

    Raycast into GUI?http://forum.unity3d.com/threads/raycast-into-gui.263397/ << ; Ray myray = UI ...

  3. ASCII十进制字符集

    <script> for(var i=33;i<=6000;i++){ document.write("&nbsp"+i+"&nbsp ...

  4. 关于OPencv版本不符合,相关库变化问题

    由于OPencv发展迅速,已经省略了很多原来的库文件,奈何自己才疏学浅,所以只能把OPencv 1.0中的相关版本中的库文件一直过去. 链接: http://pan.baidu.com/s/1qY1Z ...

  5. 51nod 1027大数乘法

    题目链接:51nod 1027大数乘法 直接模板了. #include<cstdio> #include<cstring> using namespace std; ; ; ; ...

  6. 英文缩写&名词

    DAO:Data Access Object 数据访问对象 Abstract Oriented Programing 面向借口编程 IOC: Inversion of Control 控制反转 DI: ...

  7. 常用的获取时间差的sql语句

    "select count(*) from [注册] where datediff(day,time,getdate())<1";//获取当天注册人员数 sql=" ...

  8. 收集Github上的iOS控件和开发资料

    文章来源:http://www.mobile-open.com/2015/85017.html 动画 awesome-ios-animation 收集了iOS平台下比较主流炫酷的几款动画框架 RCTR ...

  9. python leetcode 日记--231. Power of Two

    题目: Given an integer, write a function to determine if it is a power of two. class Solution(object): ...

  10. 删除IE 下输入后的清除小叉叉

    input::-ms-clear { display: none; } css去掉ie10,11中input[type="text"]后面的X图标 input[type=" ...