此程序包括UIProgressViewUIButton, UIDatePicker,UIAlert,UILabel,NSTimer

//

//  HViewController.h

//  Btn_lbl

//

//  Created by public on 13-7-18.

//  Copyright (c) 2013年  All rights reserved.

//

#import <UIKit/UIKit.h>

@interface HViewController : UIViewController

@property (retain, nonatomic) IBOutlet UIDatePicker *hdatePicker;

@property (retain, nonatomic) IBOutlet UILabel *lblText;

@property (retain, nonatomic) IBOutlet UIProgressView *progress;

@property (retain, nonatomic) IBOutlet UIProgressView *progressBar;

@property (retain, nonatomic) IBOutlet UIButton *btnStart;

@property (retain, nonatomic) IBOutlet UIButton *btnStop;

@property(retain,nonatomic)IBOutlet NSTimer* timer;

- (IBAction)btnClick:(id)sender;

- (IBAction)dateChange;

- (IBAction)startProgress:(id)sender;

- (IBAction)stopProgress:(id)sender;

- (IBAction)startHeadProgress:(id)sender;

@end

//

//  HViewController.m

//  Btn_lbl

//

//  Created by public on 13-7-18.

//  Copyright (c) 2013年 . All rights reserved.

//

#import "HViewController.h"

@interface HViewController ()

@end

@implementation HViewController

#pragma mark 加载数据

- (void)viewDidLoad

{

[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

NSDate* hdate=[NSDate date];

[_hdatePicker setDate:hdate animated:YES];

}

- (void)didReceiveMemoryWarning

{

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

- (void)dealloc {

[_lblText release];

[_hdatePicker release];

[_progress release];

[_timer release];

[_btnStart release];

[_progressBar release];

[_btnStop release];

[super dealloc];

}

#pragma mark -按钮的测试点击事件

- (IBAction)btnClick:(id)sender{

UIButton * button=(UIButton *)sender;

_lblText.font=[UIFont fontWithName:@"Bold" size:25];

_lblText.backgroundColor=[UIColor blueColor];

_lblText.textColor=[UIColor whiteColor];

_lblText.text=@"中华";

NSString* tittle=[NSString stringWithFormat:@"UILabel的内容是:%@,UIButton 的 tag 是 %d",_lblText.text,button.tag];

NSString* message=[button currentTitle];

UIAlertView* alert=[[UIAlertView alloc]initWithTitle:tittle message:message delegate:self cancelButtonTitle:@"OK" otherButtonTitles:@"cancel", nil];

[alert show];

[alert release];

}

#pragma mark -日历的改变

- (IBAction)dateChange {

NSDate* date=[_hdatePicker date];

NSDateFormatter *format=[[NSDateFormatter alloc]init];

[format setDateStyle:NSDateFormatterShortStyle];

[format setTimeStyle:NSDateFormatterShortStyle];

_lblText.text=[NSString stringWithFormat:@"%@",[format stringFromDate:date]];

[format release];

}

#pragma mark -Progress View进度条

-(void)changetimer

{

_progress.progress+=0.001f;

self.progressBar.progress+=0.001f;

}

- (IBAction)startProgress:(id)sender {

_timer=[NSTimer scheduledTimerWithTimeInterval:0.03f target:self selector:@selector(changetimer) userInfo:nil repeats:YES];

[_timer retain];

[_btnStart setEnabled:NO];

[_btnStop setEnabled:YES];

}

- (IBAction)stopProgress:(id)sender {

[_timer invalidate];

[_timer release];

[_btnStart setTitle:@"继续" forState:UIControlStateNormal];

UIColor *color=[UIColor blueColor];

[_btnStart setTitleColor:color forState:UIControlStateNormal];

[_btnStart setEnabled:YES];

[_btnStop setEnabled:NO];

}

- (IBAction)startHeadProgress:(id)sender {

_progress.progress=0.0f;

_progressBar.progress=0.0f;

[_btnStart setTitle:@"开始" forState:UIControlStateNormal];

UIColor *color=[UIColor blueColor];

[_btnStart setTitleColor:color forState:UIControlStateNormal];

}

@end

最新文章

  1. [django]django 在apache2上部署静态文件如何加载
  2. hadoop2.2.0伪分布式搭建3--安装Hadoop
  3. 递归算法(三)&mdash;&mdash;多项分布问题
  4. NLS_LANG
  5. 用Reveal分析第三方App的UI
  6. ASP.NET中如何读取和写入注册表
  7. SAM4E单片机之旅——23、在AS6(GCC)中使用FPU
  8. php读取memcahed java session
  9. cadence通过孔焊盘的制作
  10. 如何让Vim显示dos下的^M符号
  11. 闲话:你今天OO了吗?
  12. linux下环境搭建比较
  13. linux之SQL语句简明教程---UNION ALL
  14. float 浮点数与零值0比较大小
  15. CSS3属性之border-radius
  16. 高速理解掌握node.js 字符编码,确码过程 以及base64编解码原理
  17. HDU 5652 India and China Origins 二分优化+BFS剪枝
  18. 【Ubuntu】您没有查看“sf_VirtualDisk”的内容所需的权限。
  19. dashDB - Creating a table with CLOB column type
  20. 1.3创建项目「深入浅出ASP.NET Core系列」

热门文章

  1. Android客户端token简介和简单应用
  2. 伸展树 Splay Tree
  3. [改善Java代码]枚举和注解结合使用威力更大
  4. [改善Java代码]不同的场景使用不同的泛型通配符
  5. Linux(CentOS)安装rar和unrar以及rar和unrar命令的使用
  6. [未完成][Mooc]关于IO总结
  7. atomikos分布式事务的几个坑
  8. winform 渐变(非API)
  9. UML——类和对象
  10. Ubuntu Linux 分区简易教程