- (NSString *)selectMonthWith:(NSInteger)month
{
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
dateFormatter.dateFormat = @"yyyy年MM月";
NSDateComponents *BeforeDate = [[NSDateComponents alloc] init];
BeforeDate.month = month;
NSDate *selectDay = [[NSCalendar currentCalendar] dateByAddingComponents:BeforeDate toDate:_currentDate options:0];
NSString *dayStr = [dateFormatter stringFromDate:selectDay];
RMLog(@"%@",dayStr);
_currentDate = selectDay;
return dayStr;
}
调用直接[self selectMonthWith:1]就可以,数字个数代表操作一次跳转几个月,-1代表减一个月,1代表加一个月,当把beforeDate.month属性换成day或year时则表示跳转的单位为日或年