首页 > 其他 > 详细

UI4_UIStepper与UIProgressView

时间:2015-07-11 16:16:59      阅读:214      评论:0      收藏:0      [点我收藏+]
//
//  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

 

UI4_UIStepper与UIProgressView

原文:http://www.cnblogs.com/0515offer/p/4638795.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!