• UIDatePickerView实现时间滚动轮播效果


     1 - (void)viewDidLoad  
     2 {  
     3     [super viewDidLoad];  
     4     // Do any additional setup after loading the view.  
     5     self.title = @"第二页";  
     6     self.view.backgroundColor = [UIColor orangeColor];  
     7       
     8     UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];  
     9     view = self.view;  
    10     UIDatePicker *datePicker = [[UIDatePicker alloc] initWithFrame:CGRectMake(0, 80, 320, 300)];  
    11     datePicker.backgroundColor = [UIColor magentaColor];  
    12     datePicker.date = [NSDate date];  
    13     datePicker.datePickerMode = UIDatePickerModeDateAndTime;  
    14     [view addSubview:datePicker];  
    15       
    16     // 添加一个按钮  
    17     UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];  
    18     button.frame = CGRectMake(100, 300, 120, 50);  
    19     [button setTitle:@"时间" forState:UIControlStateNormal];  
    20     [button addTarget:self action:@selector(buttonEventMathod:) forControlEvents:UIControlEventTouchDown];  
    21     [self.view addSubview:button];  
    22       
    23     [view release];  
    24 }  
    25 -(void)buttonEventMathod:(UIButton *)button  
    26 {  
    27     UIDatePicker *picker = (UIDatePicker *)[self.view viewWithTag:100];  
    28     NSDateFormatter *formatter = [[NSDateFormatter alloc] init];  
    29     formatter.dateFormat = @"YYYY-MM-DD hh:mm:ss-aa";  
    30     NSLog(@"格式化时间:%@", [formatter stringFromDate:picker.date]);  
    31 }  
    有人说:爱上一座城,是因为城里住着某个人,能够与所爱的人在一起,连光阴都是美的。即便粗茶淡饭,修篱种田,只要有你陪伴就好。那么,找一个青山绿水的地方,寻一处幽静的茅舍,或是云水禅心的庭院,那里有晴朗的阳光和静谧的悠然,还有你明媚的笑脸。掬一捧花香在平淡的日子,握着一路相随的暖意,让爱的馨香在柴米油盐中升腾;在一杯茶的温情里,体味生活的诗意;在一碗粥的清淡中,感受生活的浪漫,每天清晨你和阳光都在,便是我的幸福。——春暖花开 《择一城终老,遇一人白首》
  • 相关阅读:
    mysql学习日志
    Python学习day10 Javascript/Jquery
    Python学习day07 多线程多进程及主机管理
    Linux基本命令
    django 用户认证/Excel导入Mysql
    转:iptables详解
    Python django前端导入Excel脚本
    Python学习day08 分布式监控系统开发实战
    Subline Text2
    MySQL 常用函数分析
  • 原文地址:https://www.cnblogs.com/-Eric-Liu/p/5564048.html
Copyright © 2020-2023  润新知