//
// ViewController.m
// UI4_UIStepper与UIProgressView
//
// Created by zhangxueming on 15/7/7.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "ViewController.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
//步进器(94*29)
UIStepper *step = [[UIStepper alloc] initWithFrame:CGRectMake(100, 200, 0, 0)];
NSLog(@"step = %@", step); //设置步进器的连续性
step.continuous = YES; //设置步长
step.stepValue = 0.01;
//设置最小值
step.minimumValue = 0;
//设置最大值
step.maximumValue = 1;
//
step.tintColor = [UIColor redColor];
//
[step setBackgroundImage:[UIImage imageNamed:@"truckmin"] forState:UIControlStateNormal];
//添加点击事件
[step addTarget:self action:@selector(stepValueChange:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:step]; //进度条
UIProgressView *progress = [[UIProgressView alloc] initWithProgressViewStyle:UIProgressViewStyleDefault];
progress.frame = CGRectMake(10, 400, self.view.frame.size.width-20, 10);
progress.tintColor = [UIColor cyanColor];
progress.trackTintColor = [UIColor redColor];
//进度
progress.progress = 0.0;
progress.tag = 100;
[self.view addSubview:progress]; } - (void)stepValueChange:(UIStepper *)step
{
NSLog(@"%.2f", step.value);
UIProgressView *progressView = (UIProgressView *)[self.view viewWithTag:100];
progressView.progress = step.value; } - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end