最近做项目需要制作一个活动报名的页面。其中需要定制一个简单的日历表来活动报名,大概效果
活动选择时间时根据当前时间之后7天的7天内可以活动报名
#define CURRENT_Date [NSDate date]
#import "CalendarVC.h"
@interface CalendarVC ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout>
{
UILabel *_yearLabel;
NSDate *_date;
NSInteger _isCurrentMouth;// 0 当前月(默认) -1 以前 1 后一个月 -1 后面不可用
NSInteger _day;//当前日子;
NSInteger _spaceDay;//当前月份活动天数;
}
@property (nonatomic, strong) UICollectionView *collectionView;
@end
@implementation CalendarVC
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.view.backgroundColor = [UIColor colorWithWhite:0.95 alpha:1];
UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 64, self.view.frame.size.width, 60)];
backView.backgroundColor = [UIColor colorWithWhite:0.5 alpha:1];
[self.view addSubview:backView];
UIButton *lastButton = [[UIButton alloc] initWithFrame:CGRectMake(5, 2, 80, 30)];
lastButton.titleLabel.font = [UIFont systemFontOfSize:14];
[lastButton setTitle:@"上一月" forState:UIControlStateNormal];
[backView addSubview:lastButton];
[lastButton addTarget:self action:@selector(clcikLastButton) forControlEvents:UIControlEventTouchUpInside];
UIButton *nextButton = [[UIButton alloc] initWithFrame:CGRectMake(self.view.frame.size.width - 85, 2, 80, 30)];
[nextButton setTitle:@"下一月" forState:UIControlStateNormal];
[backView addSubview:nextButton];
nextButton.titleLabel.font = [UIFont systemFontOfSize:14]