iOS5新控件UIStepper应用示例
2012-01-12 16:13
423 查看
在iOS5中增加了一个UIStepper的新控件,UIStepper可以连续增加或减少一个数值。控件的外观是两个水平并排的按钮构成,一个显示为“+”,一个显示为“-”。如下图所示:
该控件一个有趣的特征是当用户按住“+”“-”按钮时,根据按住的时间长度,控件值的数字也以不同的数字改变。按住的时间越长,数值改变的越快。可以为UIStepper设定一个数值范围,比如0-99。
下面是UIStepper应用范例代码:
文章出处:http://www.ctolive.com/space-1023-do-blog-id-2068.html
该控件一个有趣的特征是当用户按住“+”“-”按钮时,根据按住的时间长度,控件值的数字也以不同的数字改变。按住的时间越长,数值改变的越快。可以为UIStepper设定一个数值范围,比如0-99。
下面是UIStepper应用范例代码:
// Create a label to show the value in the stepper label = [[UILabel alloc] initWithFrame:CGRectMake(10, 20, 100, 30)]; [label setTextColor:[UIColor whiteColor]]; [label setBackgroundColor:[UIColor clearColor]]; [label setTextAlignment:UITextAlignmentLeft]; [label setText: @"Quantity:"]; [[self view] addSubview:label]; // Frame defines location, size values are ignored UIStepper *stepper = [[UIStepper alloc] initWithFrame:CGRectMake(120, 20, 0, 0)]; // Set action target and action for a particular value changed event [stepper addTarget:self action:@selector(stepperPressed:) forControlEvents:UIControlEventValueChanged]; // Set min and max [stepper setMinimumValue:0]; [stepper setMaximumValue:99]; // Value wraps around from minimum to maximum [stepper setWraps:YES]; // If continuos (default), changes are sent for each change in stepper, // otherwise, change event occurs once user lets up on button [stepper setContinuous:NO]; // To change the increment value for each step // (default is 1) [stepper setStepValue:10];
文章出处:http://www.ctolive.com/space-1023-do-blog-id-2068.html
相关文章推荐
- EXCEL Range对象基本操作应用示例(1)
- PCA、SVD应用示例:低维投影可视化
- 效率测试小工具runstats学习及应用示例
- Struts2+Spring2+Hibernate3 web应用示例(六)
- Struts2+Spring2+Hibernate3 web应用示例(六)
- Spring Boot应用的极速部署脚本示例代码
- 应用备份脚本示例
- 应用层读写nandflash示例
- 【Android应用开发】 Universal Image Loader ( 使用简介 | 示例代码解析 )
- jQuery学习笔记---阻止事件发生及事件发生顺序及表单提交示例应用
- JPetStore Demo示例改进和讲解-轻量级J2EE技术框架应用
- 数据收集用户界面解决方案2--示例应用
- Delphi泛型应用示例之二:通用数据池
- ARM嵌入式Linux设备树简介及应用示例
- lucene全文检索应用示例及代码简析
- IOCP以及扩展Windows socket函数应用示例
- Oracle 细粒度审计(FGA)详解及应用示例
- Yii2框架redis基本应用示例
- JavaScript中奇葩的假值示例应用
- WebRTC VideoEngine综合应用示例(一)——视频通话的基本流程(转)