UIStepper使用的具体解释的控制
2015-08-20 15:43
573 查看
UIStepper控件类似于UISlider控件,但它有“+”和“-”两个button,单击当中一个可使属性value值递增或递减。
如声音、速度、图片等的大小均可使用该控件操作。今天以图片为例简单解说UIStepper的用法。
(1)新建一个Single View Application 项目,全名为“UIStepperTest”。
![](http://www.it165.net/uploadfile/2013/0506/20130506093621529.png)
![](http://www.it165.net/uploadfile/2013/0506/20130506093632427.png)
(2)选择ViewController.xib。改动View的Size属性值为None。
![](http://www.it165.net/uploadfile/2013/0506/20130506093651760.png)
(3)在xib中加入一个UIImageView控件和一个UIStepper控件。分别调整其位置和大小并给UIImageView控件加入IBOutlet变量和给UIStepper加入IBOutlet变量和IBAction响应函数。
![](http://www.it165.net/uploadfile/2013/0506/20130506093840600.png)
![](http://www.it165.net/uploadfile/2013/0506/20130506093841934.png)
![](http://www.it165.net/uploadfile/2013/0506/20130506093841882.png)
切换到ViewController.m文件。在
@implementation ViewController
后加入代码:
@synthesize stepper;
@synthesize imageView;
(4)选中项目,右击。新建Group,命名为image。向当中加入图片。
![](http://www.it165.net/uploadfile/2013/0506/20130506093736147.png)
(5)改动
- (void)viewDidLoad
中的代码例如以下:
view
sourceprint?
(6)在UIStepper的响应函数:
- (IBAction)stepperValueChanged:(UIStepper *)sender
中加入代码例如以下:
- (IBAction)stepperValueChanged:(UIStepper *)sender {
int stepValue = sender.value;
self.imageView.bounds = CGRectMake(self.imageView.bounds.origin.x, self.imageView.bounds.origin.y, stepValue, stepValue);
}
执行程序。例如以下:
![](http://www.it165.net/uploadfile/2013/0506/20130506093841940.png)
如声音、速度、图片等的大小均可使用该控件操作。今天以图片为例简单解说UIStepper的用法。
(1)新建一个Single View Application 项目,全名为“UIStepperTest”。
![](http://www.it165.net/uploadfile/2013/0506/20130506093621529.png)
![](http://www.it165.net/uploadfile/2013/0506/20130506093632427.png)
(2)选择ViewController.xib。改动View的Size属性值为None。
![](http://www.it165.net/uploadfile/2013/0506/20130506093651760.png)
(3)在xib中加入一个UIImageView控件和一个UIStepper控件。分别调整其位置和大小并给UIImageView控件加入IBOutlet变量和给UIStepper加入IBOutlet变量和IBAction响应函数。
![](http://www.it165.net/uploadfile/2013/0506/20130506093840600.png)
![](http://www.it165.net/uploadfile/2013/0506/20130506093841934.png)
![](http://www.it165.net/uploadfile/2013/0506/20130506093841882.png)
切换到ViewController.m文件。在
@implementation ViewController
后加入代码:
@synthesize stepper;
@synthesize imageView;
(4)选中项目,右击。新建Group,命名为image。向当中加入图片。
![](http://www.it165.net/uploadfile/2013/0506/20130506093736147.png)
(5)改动
- (void)viewDidLoad
中的代码例如以下:
view
sourceprint?
01.
- (
void
)viewDidLoad
02.
{
03.
[super viewDidLoad];
04.
// Do any additional setup after loading the view, typically from a nib.
05.
06.
UIImage *im = [UIImage imageNamed:@
"QQ20130505-2"
];
07.
self.imageView.image = im;
08.
self.stepper.minimumValue = im.size.width/5;
09.
self.stepper.maximumValue = im.size.height>im.size.width? im.size.height:im.size.width;
10.
self.stepper.stepValue = 20;
11.
self.stepper.value = im.size.height;
12.
}
(6)在UIStepper的响应函数:
- (IBAction)stepperValueChanged:(UIStepper *)sender
中加入代码例如以下:
- (IBAction)stepperValueChanged:(UIStepper *)sender {
int stepValue = sender.value;
self.imageView.bounds = CGRectMake(self.imageView.bounds.origin.x, self.imageView.bounds.origin.y, stepValue, stepValue);
}
执行程序。例如以下:
![](http://www.it165.net/uploadfile/2013/0506/20130506093841940.png)
![](http://www.it165.net/uploadfile/2013/0506/20130506093843454.png)
相关文章推荐
- easyui的tab切换问题,第一个总显示最后一个
- iOS开发-Day27UISwitch&UISlider&UIStepper&UISegmentedControl
- easy ui 表单元素input控件后面加说明(红色)
- android-UI组件实例大全(七)------Adapter类One之ListView
- easyui icon总结
- HBuilder快捷键
- PAT 1051. Pop Sequence (25)
- Hbuilder检测不到真机的解决方法
- CodeForces-447C DZY Loves Sequences
- 也谈kendoUI的grid.
- Android Call requires API level 11 (current min is 8)的解决方案
- iOS开发-Day26-UILabel&UIButton&UITextField
- LeetCode "Verify Preorder Sequence in Binary Search Tree"
- leetcode - Unique Paths
- serialVersionUID作用
- iOS开发:代码通用性以及其规范 第一篇(附带,自定义UITextView\进度条\双表显示\瀑布流 代码设计思路)
- UE4 Mac 使用Xcode编译教程
- [转]VS编译duilib项目时候的错误解决方法整理
- iOS开发-UIImageView的contentMode属性
- UIView的使用setNeedsDisplay