ios 签到功能 补签功能 日历

iOS 日历 签到功能

公司APP涉及到签到功能,具体以当前日期为分界线。

也就是今天之前的日期分为已签到和未签到并且未签到可以补签(涉及到3种UI效果)。今天分为已签到和未签到(2种UI效果),今天以后的显示为日期(1种UI效果)。

下面是效果图奉上。

红色部分为组头,显示的是当前年月。

绿色部分是当前月份的日期以及之前的日期。

数字部分为当前日期后面的日期。

这样就可以自定义出来今天日期之前的日期是否签到。


下面是具体代码实现。

直接新建工程,在新工程的viewcontroller.m里面直接拷贝如下代码:

#import "ViewController.h"

#import "NSDate+LYWCalendar.h"

#import "LYWCollectionViewCell.h"

#import "LYWCollectionReusableView.h"

#define ScreenWidth [UIScreen mainScreen].bounds.size.width

#define ScreenHeight [UIScreen mainScreen].bounds.size.height

#define NumberMounthes 1

@interface ViewController ()<UICollectionViewDelegate,UICollectionViewDataSource,UICollectionViewDelegateFlowLayout>{

    //自动布局

    UICollectionViewFlowLayout *_layout;

    //表格视图

    UICollectionView *_collectionView;

    //当月第一天星期几

    NSInteger firstDayInMounthInWeekly;

    NSMutableArray *_firstMounth;

    

    NSMutableArray *_dateArray;

    

}


@end

static NSString *cellID =@"cellID";

static NSString *headerID =@"headerID";

static NSString *footerID =@"footerID";

@implementation ViewController


- (void)viewDidLoad {

    [superviewDidLoad];

    

    self.automaticallyAdjustsScrollViewInsets =NO;//关闭自动适应

    NSArray *weekTitleArray =@[@"",@"",@"",@"",@"",@"",@""];

    for (int i =0; i < weekTitleArray.count; i++) {

        UILabel *weekTitleLable = [[UILabelalloc]initWithFrame:CGRectMake(i * ((ScreenWidth/(weekTitleArray.count))),64,ScreenWidth/(weekTitleArray.count ),30)];

        if (i ==0 || i ==6) {

          

            weekTitleLable.textColor = [UIColorblackColor];

      

        }else{

            weekTitleLable.textColor = [UIColorblackColor];

        }

        weekTitleLable.text = [weekTitleArrayobjectAtIndex:i];

        weekTitleLable.textAlignment =NSTextAlignmentCenter;

        [self.viewaddSubview:weekTitleLable];

    }

    [selfcreateData];

    [selfcreateCollectionView];

}

-(void)createCollectionView{

    

    //设置collectionView及自动布局,代理方法尤为重要

    _layout = [[UICollectionViewFlowLayoutalloc]init];

    //头部始终在顶端

    _layout.sectionHeadersPinToVisibleBounds =YES;

    //头部视图高度

    _layout.headerReferenceSize =CGSizeMake(414,40);

    _layout.minimumLineSpacing =0;

    _layout.minimumInteritemSpacing =0;

    _collectionView = [[UICollectionViewalloc]initWithFrame:CGRectMake(0,64 + 30, ScreenWidth,ScreenHeight -64 -30)collectionViewLayout:_layout];

    _collectionView.backgroundColor = [UIColorwhiteColor];

    //注册表格

    [_collectionViewregisterClass:[LYWCollectionViewCellclass]forCellWithReuseIdentifier:cellID];

    //

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值