zoukankan      html  css  js  c++  java
  • UIStepper使用的具体解释的控制

    UIStepper控件类似于UISlider控件,但它有“+”和“-”两个button,单击当中一个可使属性value值递增或递减。

    如声音、速度、图片等的大小均可使用该控件操作。今天以图片为例简单解说UIStepper的用法。

    (1)新建一个Single View Application 项目,全名为“UIStepperTest”。

     




     

    (2)选择ViewController.xib。改动View的Size属性值为None。

     


     

    (3)在xib中加入一个UIImageView控件和一个UIStepper控件。分别调整其位置和大小并给UIImageView控件加入IBOutlet变量和给UIStepper加入IBOutlet变量和IBAction响应函数。

     

      


    切换到ViewController.m文件。在

    @implementation ViewController

    后加入代码:

    @synthesize stepper;
    @synthesize imageView;

    (4)选中项目,右击。新建Group,命名为image。向当中加入图片。

     


     

    (5)改动

    - (void)viewDidLoad

    中的代码例如以下:

     

    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服务器实现文件上传与下载(二)
    Http服务器实现文件上传与下载(三)
    NHibernate VS IbatisNet
    5. Element-UI的基本使用
    4. Vue脚手架
    3. Vue单文件组件
    webpack中的加载器
    webpack
    02.模块化相关规范
    01.前端工程化的学习目标
  • 原文地址:https://www.cnblogs.com/mfrbuaa/p/4745377.html
Copyright © 2011-2022 走看看