25.VRGCalendar一款支持标记自定义日期的日历选择器
2015-09-01 17:18
423 查看
详情参见life365
#pragma mark - calendar Delegate
- (void)calendarView:(VRGCalendarView *)calendarView dateSelected:(NSDate *)date
{
NSDate * today = [NSDate date];
//如果选择的时间跟明天一样
if ([today compare:date] == NSOrderedAscending) {
[CustomTools getMessageTitle:@"温馨提示:" withMessage:@"别闹了,要穿越吗?"];
}else{
rightButton1.hidden = NO;
rightButton2.hidden = NO;
_imageView.image = [UIImage imageNamed:@"rowdown"];
[self hiddenCalendarView];
//日期比较
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSString *todayDayStr = [dateFormatter stringFromDate:today];
NSString *anotherDayStr = [dateFormatter stringFromDate:date];
NSDate *dateA = [dateFormatter dateFromString:todayDayStr];
NSDate *dateB = [dateFormatter dateFromString:anotherDayStr];
NSComparisonResult result = [dateA compare:dateB];
if (result == NSOrderedSame) {
[self navTitle:@"今天"];
[self pushToPlayBack:todayDayStr andTimeTitle:@"今天"];
}else{
[self navTitle:[self dateToString:date]];
[self pushToPlayBack:anotherDayStr andTimeTitle:[selfdateToString:date]];
}
}
}
- (void)calendarView:(VRGCalendarView *)calendarView switchedToMonth:(int)month targetHeight:(float)targetHeight animated:(BOOL)animated
{
//划线 获取当前月份
// NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
// NSDateComponents *comps = [[NSDateComponents alloc] init];
// NSInteger unitFlags = NSYearCalendarUnit |NSMonthCalendarUnit |NSDayCalendarUnit |NSWeekdayCalendarUnit |NSHourCalendarUnit |NSMinuteCalendarUnit |NSSecondCalendarUnit;
// comps = [calendar components:unitFlags fromDate:[NSDate date]];
// int currentmonth = [comps month];
//
// if (month==currentmonth) {
// NSArray *dates = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:5], nil];
// [calendarView markDates:dates];
// }
}
#pragma mark - calendar Delegate
- (void)calendarView:(VRGCalendarView *)calendarView dateSelected:(NSDate *)date
{
NSDate * today = [NSDate date];
//如果选择的时间跟明天一样
if ([today compare:date] == NSOrderedAscending) {
[CustomTools getMessageTitle:@"温馨提示:" withMessage:@"别闹了,要穿越吗?"];
}else{
rightButton1.hidden = NO;
rightButton2.hidden = NO;
_imageView.image = [UIImage imageNamed:@"rowdown"];
[self hiddenCalendarView];
//日期比较
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
[dateFormatter setDateFormat:@"yyyy-MM-dd"];
NSString *todayDayStr = [dateFormatter stringFromDate:today];
NSString *anotherDayStr = [dateFormatter stringFromDate:date];
NSDate *dateA = [dateFormatter dateFromString:todayDayStr];
NSDate *dateB = [dateFormatter dateFromString:anotherDayStr];
NSComparisonResult result = [dateA compare:dateB];
if (result == NSOrderedSame) {
[self navTitle:@"今天"];
[self pushToPlayBack:todayDayStr andTimeTitle:@"今天"];
}else{
[self navTitle:[self dateToString:date]];
[self pushToPlayBack:anotherDayStr andTimeTitle:[selfdateToString:date]];
}
}
}
- (void)calendarView:(VRGCalendarView *)calendarView switchedToMonth:(int)month targetHeight:(float)targetHeight animated:(BOOL)animated
{
//划线 获取当前月份
// NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
// NSDateComponents *comps = [[NSDateComponents alloc] init];
// NSInteger unitFlags = NSYearCalendarUnit |NSMonthCalendarUnit |NSDayCalendarUnit |NSWeekdayCalendarUnit |NSHourCalendarUnit |NSMinuteCalendarUnit |NSSecondCalendarUnit;
// comps = [calendar components:unitFlags fromDate:[NSDate date]];
// int currentmonth = [comps month];
//
// if (month==currentmonth) {
// NSArray *dates = [NSArray arrayWithObjects:[NSNumber numberWithInt:1],[NSNumber numberWithInt:5], nil];
// [calendarView markDates:dates];
// }
}
相关文章推荐
- source /build/envsetup.sh和lunch)
- LPCScrypt, DFUSec : USB FLASH download, programming, and security tool, LPC-Link 2 Configuration tool, Firmware Programming
- ovirt-engine安装
- js参数传递分析
- 每日python(5)
- 关闭Linux里边的selinux
- Qt MinGW与MSVC对比
- [置顶] Excel入门指导
- SpringMVC XSS之HttpServletRequestWrapper使用风险与应对方案
- 608 畅通工程【并查集】
- 机器学习实战之KNN算法
- 小心移动支付八大诈骗陷阱----阿冬专栏
- 23.iOS学习笔记(十四)——发短信
- 24. iOS中文网址路径转换URLEncode
- 【工具类】ViewHolder模式超简洁写法
- Linux 信号
- 数据连接池
- Z-Score数据标准化处理(python代码)
- Oracle使用笔记(1)
- 带‘.‘和’*‘的字符串匹配