码迷,mamicode.com
首页 > 其他好文 > 详细

ISO UiView和UiDatePiceker的搭配

时间:2014-06-15 00:08:58      阅读:279      评论:0      收藏:0      [点我收藏+]

标签:blog   http   tar   ext   color   com   

效果图如下:

bubuko.com,布布扣

功能代码如下:

//datepicker
UIView *myView=[[UIView alloc]initWithFrame:CGRectMake(20, 100, 280, 224)];
myView.layer.borderWidth=2;
myView.layer.borderColor=[[UIColor blackColor]CGColor];
myView.backgroundColor=[UIColor grayColor];
UILabel *l=[[UILabel alloc]initWithFrame:CGRectMake(2, 2, 276, 20)];
l.text=@"请您选择时间:";
l.backgroundColor=[UIColor blackColor];
l.textColor=[UIColor redColor];
[myView addSubview:l];

UIDatePicker *datepicker=[UIDatePicker new];
datepicker.frame=CGRectMake(0, 24, 280, 150);
datepicker.datePickerMode=UIDatePickerModeDateAndTime;
[myView addSubview:datepicker];

UIButton *btnok=[UIButton buttonWithType:UIButtonTypeRoundedRect];
btnok.frame=CGRectMake(50, 180, 80, 30);
[btnok setTitle:@"确 定" forState:UIControlStateNormal];
btnok.backgroundColor=[UIColor blackColor];

[btnok setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
[btnok addTarget:self action:@selector(btnokAction) forControlEvents:UIControlEventTouchUpInside];
[myView addSubview:btnok];

[self.view addSubview:myView];

按钮时间如下:

 -(void)btnokAction
{
    UIAlertView *alert=[[UIAlertView alloc]initWithTitle:@"信息提示:"
                                                 message:@"收到"
                                                delegate:nil
                                       cancelButtonTitle:@"确定"
                                       otherButtonTitles:nil];
    [alert show];

ISO UiView和UiDatePiceker的搭配,布布扣,bubuko.com

ISO UiView和UiDatePiceker的搭配

标签:blog   http   tar   ext   color   com   

原文地址:http://www.cnblogs.com/quhongyue/p/3786075.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!