08-2 UISwitch and UIStepper
来源:互联网 发布:淘宝上怎么买氰化钾 编辑:程序博客网 时间:2024/05/29 15:05
UISwitch(开关控件)
UISwitch:提供了一个简单的开/关UI元素,类似于传统的物理开关,开关的可配置选项很少,应将其用于处理布尔值创建一个UISwitch并初始化
UISwitch *switchView = [[UISwitch alloc] initWithFrame:CGRectMake(200, 200, 100, 40)];[self.window addSubview:switchView];获得开关状态BOOL setting = switchView.isOn;NSLog(@"%d",setting);设置开关状态 NO关闭状态,YES打开状态[switchView setOn:setting animated:YES];设置开光的切换switchView.onTintColor = [UIColor orangeColor];设置按钮的颜色switchView.thumbTintColor = [UIColor redColor];开关控件边框的颜色switchView.tintColor = [UIColor purpleColor];添加触发事件[switchView addTarget:self action:@selector(switchAction:) forControlEvents:UIControlEventValueChanged];
UIStepper(数字控件)
它可以递进式输入数量。UIStepper继承自UIControl,它主要的事件是UIControlEventValueChanged,每当它的值改变了就会触发这个事件。
UIStepper初始化UIStepper *stepper = [[UIStepper alloc] initWithFrame:CGRectMake(50, 50, 100, 40)];[self.window addSubview:stepper];设置最大值和最小值,以及每次加减时的值,每按一次减号,value就会自动减去一定的数值(数值大小由stepValue决定),每按一次加号,value就会自动增加一定的数值(数值大小由stepValue决定)stepper.minimumValue = 0.1;//最小值 stepper.maximumValue = 10.0;//最大值 stepper.stepValue = 0.1;设置是否循环和是否连续stepper.continuous = YES;//默认是yes判断是否循环,即到最大值后又从最小值开始stepper.wraps = YES;设置颜色stepper.tintColor = [UIColor purpleColor];//设置按钮的颜色;[stepper setBackgroundColor:[UIColor orangeColor]];//设置背景颜色[stepper setBackgroundImage:[UIImage imageNamed:@"001.png"] forState:UIControlStateNormal];//设置背景图片数字控件的触发事件[stepper addTarget:self action:@selector(stepperAction:) forControlEvents:UIControlEventValueChanged];
《代码演示》
0 0
- 08-2 UISwitch and UIStepper
- UISwitch / UIStepper
- Swift基础(二十)UISwitch And UIStepper
- UISegmentedControll,UISlider,UISwitch,UIStepper
- OC-UIAlertController& UIStepper& UISlider& UISwitch
- UISlider、UIStepper、UISegmentControl、UISwitch、UIProgressView、UIActivityIndicatorView
- iosui学习中的课堂笔记 UISegmentedControl。UISlider。UIStepper。UISwitch。
- UISegmentedControl ,UIStepper,UISwitch,UISlider综合应用(实例需求)
- UISegmentedControl,UISlider,UISwitch,代码截屏,UIStepper的简单使用
- UISwitch、UISlider、UISegmentedControl、UIActivityIndicatorView、UIStepper、UIProgress、UIAlertView--(图)
- UIStepper
- UIStepper
- UIStepper
- UIStepper
- UIStepper
- UIStepper
- UIStepper
- UIStepper
- day05 数组 排序
- nginx取资源要用get方式,post会失败
- Spark SQL 官方文档-中文翻译
- ROS学习笔记(三)::RVIZ::wiki::translation::catkin:一:Creating a workspace for catkin
- pythonchallenge(0-9)
- 08-2 UISwitch and UIStepper
- 38 用break和continue改变流程 课后
- DataSet之增删改查操作(DataGridView绑定)
- python os.path模块
- (深搜) — — hdu 1016
- ADO.NET常用方法释义
- python challenge(9-18)
- 09 UIScrollView 、 UIPageControl
- bzoj 2768: [JLOI2010]冠军调查