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

自定义UIDatePikerView

时间:2015-03-09 15:37:44      阅读:116      评论:0      收藏:0      [点我收藏+]

标签:

1、添加文件GoYearMonthDayPickerView.h .m .xib、NSDate+Helper.h .m、iCarousel.h .m

2、在Lable上显示日期

UILabel *ageLabel = [[UILabel alloc]initWithFrame:CGRectMake(120, 0, 150, 58)];
ageLabel.tag = 105;
ageLabel.text = @"1985-12-29";
ageLabel.textColor = [UIColor whiteColor];
ageLabel.textAlignment = NSTextAlignmentRight;
ageLabel.userInteractionEnabled = YES;
UITapGestureRecognizer *tapAgeLabel = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(GetDateAction:)];
[ageLabel addGestureRecognizer:tapAgeLabel];
[self.view addSubview:ageLabel];

- (void)GetDateAction:(UITapGestureRecognizer *)tap{
    NSLog(@"tap = %ld",tap.numberOfTouches);
    GOYearMonthDayPickerBox *box = [GOYearMonthDayPickerView yearMonthDayPickerBoxWithPickerDelegate:self];//定义视图窗口
    [box.yearMonthDayPicker show];//显示
}

#pragma mark -  GOYearMonthDayPickerViewDelegate 
- (void)yearMonthDayPicker:(GOYearMonthDayPickerView *)picker selectedYear:(int)year selectedMonth:(int)month selectedDay:(int)day
{
    UILabel *ageLabel = (UILabel *)[self.view viewWithTag:105];
    ageLabel.text = [NSString stringWithFormat:@"%d-%02d-%02d",year,month,day];
}

  

自定义UIDatePikerView

标签:

原文地址:http://www.cnblogs.com/yyzanll/p/4323486.html

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