左右可以滑动半年的超级日历,支持日历部分收起和自动重定向为北京时间
前后可以滑动半年的超级日历,支持日历部分收起和自动重定向为北京时间。
服务器返回的是北京时间,无论手机在那个时区或设置为那个时区,都重定向为北京时间,以保证日历的日期正确性。
BGCalendarEntity.m
#import "BGCalendarEntity.h"@implementation BGCalendarEntity- (instancetype)init
{self = [super init];if (self) {[self fillData];}return self;
}-(void)fillData
{self.list = [NSMutableArray array];self.shortList = [NSMutableArray array];self.localServerDifferenceTimeZone = 8*3600*1000 - [self getZoneTimeDifference];
}-(BOOL)leapYear : (long)currentday
{if(currentday % 400 == 0){return YES;}else if((currentday % 100 != 0) && (currentday % 4 == 0)){return YES;}else{return NO;}
}
#pragma mark - 把绝对时间转换为年/月/日格式的日期字符串
-(BGCalendarUnitEntity *)currentDateWithNowTime:(long long)nowTime
{if(nowTime < 0){return @"未知时间";}long long dateDistace = (nowTime/1000 + 8*3600)/86400;long long n = 0;long i,j,k,m;long month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};NSMutableDictionary *dic = [self getStartDayWithminDistace:dateDistace];i = [dic[@"startDay"] longValue];n = [dic[@"startValue"] longLongValue];for(j = 1, k = 1; (n <= dateDistace) && (i < 3000); i++){for(j = 1; j <= 12 ; j++){m = month[j - 1];for(k = 1; k <= m; k++){n++;if(n == dateDistace){return [NSString stringWithFormat:@"%ld/%ld/%ld", i, j,k];}}if((j == 2) && [ self leapYear: i]){n++;if(n == dateDistace){return [NSString stringWithFormat:@"%ld/%ld/%ld", i, j,k];}}}}return nil;
}
-(long long)getZoneTimeDifference
{NSDate *date = [NSDate date]; // 获得时间对象NSTimeZone *zone = [NSTimeZone systemTimeZone]; // 获得系统的时区NSTimeInterval time = [zone secondsFromGMTForDate:date]*1000;// 以秒为单位返回当前时间与系统格林尼治时间的差return (long long)time;
}-(long long)getNowTime
{long long nowTime = (long long)([[NSDate date] timeIntervalSince1970]*1000+[self getZoneTimeDifference])+self.localServerDifferenceTime + self.localServerDifferenceTimeZone;return nowTime;
}
-(long long)getStandardNowTime
{long long nowTime = (long long)([[NSDate date] timeIntervalSince1970]*1000+[self getZoneTimeDifference])+self.localServerDifferenceTime + self.localServerDifferenceTimeZone -8*3600*1000;return nowTime;
}-(NSDate *)getDateNow
{NSDate *dateNow = [[NSDate date] dateByAddingTimeInterval:([self getZoneTimeDifference] + self.localServerDifferenceTime + self.localServerDifferenceTimeZone)/1000];// 然后把差的时间加上,就是当前系统准确的时间return dateNow;
}-(NSDate *)getStandardDateNow
{NSDate *dateNow = [[NSDate date] dateByAddingTimeInterval:([self getZoneTimeDifference] + self.localServerDifferenceTime + self.localServerDifferenceTimeZone -8*3600*1000)/1000];//0时区的时间return dateNow;
}-(NSDate *)getStandardDateNowWithLocalServerDifferenceTime:(long long)localServerDifferenceTime
{NSDate *dateNow = [[NSDate date] dateByAddingTimeInterval:([self getZoneTimeDifference] + localServerDifferenceTime + self.localServerDifferenceTimeZone -8*3600*1000)/1000];// 然后把差的时间加上,就是当前系统准确的时间return dateNow;
}-(NSDate *)getStandardDateNowWithInterval:(long long)interval
{NSDate *dateNow = [[NSDate date] dateByAddingTimeInterval:([self getZoneTimeDifference] + self.localServerDifferenceTime + self.localServerDifferenceTimeZone -8*3600*1000)/1000+interval*24*3600];// 然后把差的时间加上,就是当前系统准确的时间return dateNow;
}#pragma mark - 把绝对时间转换为今天,昨天,明天,周几
-(BOOL)resetCalendarDataWithLocalServerDifferenceTime:(long long)localServerDifferenceTime
{self.localServerDifferenceTime = localServerDifferenceTime;long long nowTime = [self getNowTimeWithLocalServerDifferenceTime:localServerDifferenceTime];// (long long)([[NSDate date] timeIntervalSince1970])+ 8*3600+localServerDifferenceTime/1000;nowTime = nowTime/1000;long long maxTime = 31*8*24*3600;maxTime = nowTime + maxTime;//注意Java服务器获取到的时间是精确到毫秒的,苹果获取到的时间默认是精确到秒,若想得到毫秒需要乘以1000,反之要除以1000;获取到的绝对时间都是以零时区的时间为准,所以北京要加八个小时时间long long distace = 31*7*24*3600;//1*1*24*3600;long long minDistace = (nowTime -distace)/86400;long long maxDistace = (nowTime +distace)/86400;long long nowDistace = (nowTime)/86400;long long n = 0;long long i,j,k,m,interval;interval = 0;long month[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};NSMutableDictionary *dic = [self getStartDayWithminDistace:minDistace];i = [dic[@"startDay"] longValue];n = [dic[@"startValue"] longLongValue];long monthCount = 0;interval = 0;NSMutableArray *arr = [NSMutableArray array];NSArray *weekdays = [NSArray arrayWithObjects: @"一", @"二", @"三", @"四", @"五", @"六",@"日", nil];BGCalendarUnitEntity *minEntity = [self getWeekDatValueWithLocalServerDifferenceTime:localServerDifferenceTime interval:minDistace - nowDistace];self.minEntity = minEntity;if(minEntity){[arr addObject:minEntity];}for(j = 1, k = 1; (n <= maxDistace) && (i < 5000); i++){for(j = 1; j <= 12 ; j++){monthCount++;m = month[j - 1];for(k = 1; k <= m; k++){// if(1 == j && 1 == k)
// {// NSLog(@"n:%lld", n);
// }if(n == maxDistace){return [self updateListWithArr:arr];//[self getWeekDatValueWithIsOverNow:isOverNow interval:interval];}else if(n == minDistace){interval++;monthCount = 0;minEntity.intervalGMT = n;}else if(interval > 0){BGCalendarUnitEntity *entity = [[BGCalendarUnitEntity alloc] init];entity.intervalGMT = n;entity.weekdayIndex = (minEntity.weekdayIndex + interval)%7;entity.year = i;entity.month = j;entity.day = k;entity.yearMonth = [NSString stringWithFormat:@"%lu.%lu月", entity.year, entity.month];entity.value = [NSString stringWithFormat:@"%lu", entity.day];entity.weekName = [weekdays objectAtIndex:entity.weekdayIndex];if(n == nowDistace){entity.isShowToday = YES;self.nowEntity = entity;entity.isSelect = YES;self.selectEntity = entity;}entity.timeStamp = minEntity.timeStamp + interval*24*3600*1000;
// entity.weekdayIndex = interval;if(entity.day >= 1 && entity.day <= 7){entity.row = 0;}else if(entity.day >= 8 && entity.day <= 14){entity.row = 1;}else if(entity.day >= 15 && entity.day <= 21){entity.row = 2;}else if(entity.day >= 22 && entity.day <= 28){entity.row = 3;}else{entity.row = 4;}entity.monthCount = monthCount;[arr addObject:entity];interval++;}n++;}if((j == 2) && [ self leapYear: i]){if(n == maxDistace){return [self updateListWithArr:arr];//[self getWeekDatValueWithIsOverNow:isOverNow interval:interval];}else if(n == minDistace){interval++;monthCount = 0;minEntity.intervalGMT = n;}else if(interval > 0){interval++;BGCalendarUnitEntity *entity = [[BGCalendarUnitEntity alloc] init];entity.intervalGMT = n;entity.weekdayIndex = (minEntity.weekdayIndex + interval)%7;entity.year = i;entity.month = j;entity.day = k+1;entity.yearMonth = [NSString stringWithFormat:@"%lu.%lu月", entity.year, entity.month];entity.value = [NSString stringWithFormat:@"%lu", entity.day];entity.weekName = [weekdays objectAtIndex:entity.weekdayIndex];entity.monthCount = monthCount;if(n == nowDistace){entity.isShowToday = YES;self.nowEntity = entity;}entity.timeStamp = nowTime + (interval - distace/86400)*24*3600*1000;if(entity.day >= 1 && entity.day <= 7){entity.row = 0;}else if(entity.day >= 8 && entity.day <= 14){entity.row = 1;}else if(entity.day >= 15 && entity.day <= 21){entity.row = 2;}else if(entity.day >= 22 && entity.day <= 28){entity.row = 3;}else{entity.row = 4;}[arr addObject:entity];}n++;}}}return NO;
}-(BOOL)updateListWithArr:(NSMutableArray *)arr
{if(!self.nowEntity || ![self.nowEntity isKindOfClass:[BGCalendarUnitEntity class]] || !arr || ![arr isKindOfClass:[NSArray class]] || arr.count == 0){return NO;}NSMutableArray *tempArr = nil;
// NSMutableArray *tempList = [NSMutableArray array];NSInteger n = self.nowEntity.monthCount + 6;NSInteger m = self.nowEntity.monthCount - 6;long long tempMonthCount = 0;long long newMonthCount = 0;[self.list removeAllObjects];[self.shortList removeAllObjects];for(NSInteger i = 0; i < arr.count; i++){BGCalendarUnitEntity *entity = arr[i];if(entity.monthCount >= m && entity.monthCount <= n){if(entity.monthCount != tempMonthCount){if(tempArr){[self.list addObject:tempArr];newMonthCount++;}tempArr = [NSMutableArray array];[tempArr addObject:entity];}else{[tempArr addObject:entity];}tempMonthCount = entity.monthCount;entity.monthCount = newMonthCount;}}[arr removeAllObjects];if(tempArr){[self.list addObject:tempArr];for(NSMutableArray *arr in self.list){if(arr && [arr isKindOfClass:[NSArray class]] && arr.count > 0){BGCalendarUnitEntity *entity = arr[0];for(NSInteger i = 0; i < 7 && i < entity.weekdayIndex; i++){BGCalendarUnitEntity *emptyEntity = [[BGCalendarUnitEntity alloc] init];[arr insertObject:emptyEntity atIndex:0];}}}self.currentSection = 6;}else{return NO;}// BGCalendarUnitEntity *entity = nil;
// NSMutableArray *monthArr = nil;
// for(NSInteger i = 0; i < tempList.count; i++)
// {// monthArr = tempList[i];
// for(NSInteger j = 0; j < 35; j++)
// {// if(j < 7 && j < monthArr.count)
// {// entity = monthArr[j];
// [self.shortList addObject:entity];
// [self.list addObject:entity];
// }
// else if(j < monthArr.count)
// {// entity = monthArr[j];
// [self.list addObject:entity];
// }
// else
// {// entity = [[BGCalendarUnitEntity alloc] init];
// [self.list addObject:entity];
// }
// }
// }
// [tempList removeAllObjects];
// [arr removeAllObjects];return YES;
}-(NSMutableDictionary *)getStartDayWithminDistace:(long long)minDistace
{NSMutableDictionary *dic = [NSMutableDictionary dictionary];if(minDistace >= 18396){[dic setSafeObject:@"2020" forKey:@"startDay"];[dic setSafeObject:@"18262" forKey:@"startValue"];}else if(minDistace >= 17167){[dic setSafeObject:@"2017" forKey:@"startDay"];[dic setSafeObject:@"17167" forKey:@"startValue"];}else if(minDistace >= 16436){[dic setSafeObject:@"2015" forKey:@"startDay"];[dic setSafeObject:@"16436" forKey:@"startValue"];}else if(minDistace >= 14610){[dic setSafeObject:@"2010" forKey:@"startDay"];[dic setSafeObject:@"14610" forKey:@"startValue"];}else if(minDistace >= 10957){[dic setSafeObject:@"2000" forKey:@"startDay"];[dic setSafeObject:@"10957" forKey:@"startValue"];}else{[dic setSafeObject:@"1970" forKey:@"startDay"];[dic setSafeObject:@"0" forKey:@"startValue"];}return dic;
}-(long long)getNowTimeWithLocalServerDifferenceTime:(long long)localServerDifferenceTime
{long long nowTime = (long long)([[NSDate date] timeIntervalSince1970]*1000+[self getZoneTimeDifference])+localServerDifferenceTime;return nowTime;
}-(NSDate *)getDateNowWithLocalServerDifferenceTime:(long long)localServerDifferenceTime
{NSDate *dateNow = [[NSDate date] dateByAddingTimeInterval:([self getZoneTimeDifference] + localServerDifferenceTime/1000)];// 然后把差的时间加上,就是当前系统准确的时间return dateNow;
}-(BGCalendarUnitEntity *)getWeekDatValueWithLocalServerDifferenceTime:(long long)localServerDifferenceTimeinterval:(long long)interval
{// long long nowTime = [self getNowTimeWithLocalServerDifferenceTime:localServerDifferenceTime];NSDate *inputDate = [self getStandardDateNowWithInterval:interval];// long long nowTime = (long long)([[NSDate date] timeIntervalSince1970]+time)+localServerDifferenceTime/1000;
// NSDate *inputDate = [NSDate dateWithTimeIntervalSince1970:nowTime];NSArray *weekdays = [NSArray arrayWithObjects: @"一", @"二", @"三", @"四", @"五", @"六",@"日", nil];NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSCalendarIdentifierGregorian];NSTimeZone *timeZone = [[NSTimeZone alloc] initWithName:@"Asia/Shanghai"];
// NSTimeZone *timeZone = [NSTimeZone systemTimeZone];[calendar setTimeZone: timeZone];NSCalendarUnit calendarUnit = NSCalendarUnitWeekday;/*注意经过测试,就是你把这个日期(inputDate)置为以前的时间,通过[calendar components:calendarUnit fromDate:inputDate]你得到的theComponents.weekday也是今天所的周几,如:今天是周五,theComponents.weekday为5,和inputDate无关。所以只有你自己实现和今天的差的天数来确定具体哪天是周几才正确*/NSDateComponents *theComponents = [calendar components:calendarUnit fromDate:inputDate];NSDateComponents *comps = [calendar components:(NSCalendarUnitYear |NSCalendarUnitMonth | NSCalendarUnitDay |NSCalendarUnitHour | NSCalendarUnitMinute) fromDate:inputDate];NSInteger weekdayIndex = theComponents.weekday -2;if(weekdayIndex < 0){weekdayIndex = 6;}
// NSInteger currenWeekdayIndex = weekdayIndex;
// long long num = (interval)%7;
// weekdayIndex = (num+7+weekdayIndex)%7;NSLog(@"inputDate:%@, comps:%@,interval:%lld, weekdayIndex = %d, week:%@", inputDate, comps, interval, weekdayIndex,[weekdays objectAtIndex:weekdayIndex]);
// self.currenWeekdayIndex = currenWeekdayIndex;BGCalendarUnitEntity *entity = [[BGCalendarUnitEntity alloc] init];entity.weekdayIndex = weekdayIndex;entity.year = comps.year;entity.month = comps.month;entity.day = comps.day;
// entity.currenWeekdayIndex = currenWeekdayIndex;entity.yearMonth = [NSString stringWithFormat:@"%lu.%lu月", entity.year, entity.month];entity.value = [NSString stringWithFormat:@"%lu", entity.day];entity.weekName = [weekdays objectAtIndex:weekdayIndex];entity.isShowToday = NO;long long nowTime = [self getNowTimeWithLocalServerDifferenceTime:localServerDifferenceTime];entity.timeStamp = nowTime + interval*24*3600*1000;entity.monthCount = 0;
// entity.weekdayIndex = interval;if(entity.day >= 1 && entity.day <= 7){entity.row = 0;}else if(entity.day >= 8 && entity.day <= 14){entity.row = 1;}else if(entity.day >= 15 && entity.day <= 21){entity.row = 2;}else if(entity.day >= 22 && entity.day <= 28){entity.row = 3;}else{entity.row = 4;}return entity;//[weekdays objectAtIndex:weekdayIndex];
}@end
BGCalendarEntity.h
#import <Foundation/Foundation.h>
#import "BGCalendarUnitEntity.h"@interface BGCalendarEntity : NSObject
@property (nonatomic, strong) NSMutableArray *shortList;
@property (nonatomic, strong) NSMutableArray *list;@property(nonatomic, assign) long long localServerDifferenceTime;
@property(nonatomic, assign) long long localServerDifferenceTimeZone;
@property(nonatomic, strong) BGCalendarUnitEntity *minEntity ;
@property(nonatomic, strong) BGCalendarUnitEntity *nowEntity;
@property(nonatomic, strong) BGCalendarUnitEntity *selectEntity;
@property(nonatomic, assign) long long currentSection;- (BGCalendarUnitEntity *)currentDateWithNowTime:(long long)nowTime;
- (BOOL)resetCalendarDataWithLocalServerDifferenceTime:(long long)localServerDifferenceTime;
@end
BGCateToolView.h
#import <UIKit/UIKit.h>
//#import "BGCalendarHeadView.h"
#import "BGCateToolEntity.h"@interface BGCateToolView : BGBaseView
//@property (nonatomic, strong) BGCalendarHeadView *calendarHeadView;
//
@property (nonatomic, strong) BGCateToolUnitEntity *selectCateToolUnitEntity;
//@property (nonatomic, assign) BOOL isShowToday;
//@property (nonatomic, assign) BOOL isUnfold;
@property (nonatomic, strong) BGCateToolEntity *model;//@property (nonatomic, copy) void(^hitBlock)(NSUInteger year, NSUInteger month, NSUInteger day);
@property (nonatomic, copy) void (^selectBlock)(BGCateToolUnitEntity *selectCateToolUnitEntity);//- (void)updateWithSelectCateToolUnitEntity:(BGCateToolUnitEntity *)selectCateToolUnitEntity model:(BGCateToolEntity *)model;
@end
BGCateToolView.m
#import "BGCateToolView.h"
#import "BGCalendarFootView.h"
#import "BGCateToolCollectionCell.h"@interface BGCateToolView ()<UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout,UIGestureRecognizerDelegate>
//@property (nonatomic, assign) BOOL isEnabledSelect;
//@property (nonatomic, assign) BOOL isHiddenLine;
//@property (nonatomic, strong) UIColor *selectColor;
//@property (nonatomic, strong) UIView *roundView;
@property (nonatomic, strong) UIView *bigBackgroundView;
//@property (nonatomic, strong) UIColor *lineColor;
//@property (nonatomic, strong) UIImage *icon;
//@property (nonatomic, strong) UIImage *selectedIcon;
//
//
//
//@property (nonatomic, strong) BGCalendarFootView *calendarFootView;
@property (nonatomic, strong) UICollectionView *collectionView;
//@property (nonatomic, strong) UICollectionReusableView *headView;
//@property (nonatomic, strong) UICollectionReusableView *collectionHeadView;
//@property (nonatomic, strong) UICollectionReusableView *parentCoursesCollectionHeadView;
//@property (nonatomic, strong) UICollectionReusableView *footmarkHeadView;
//@property (nonatomic, strong) UICollectionReusableView *lineFootView;
//
//@property (nonatomic,strong) UIPanGestureRecognizer *painRecognize1;
//@property (nonatomic, assign) float shift;
//@property (nonatomic, assign) BOOL isPanGestureRecognizer;
@end@implementation BGCateToolView- (id)initWithFrame:(CGRect)frame
{self = [super initWithFrame:frame];if (self) {[self setup];}return self;
}-(void)setup
{self.backgroundColor = [UIColor clearColor];self.bigBackgroundView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, sCommonUnitFullWidth(), 20+14+2+4+15)];self.bigBackgroundView.backgroundColor = [UIColor whiteColor];[self addSubview:self.bigBackgroundView];[self.bigBackgroundView addSubview:self.collectionView];
}- (UICollectionView *)collectionView {if(!_collectionView){//创建布局UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];//创建CollectionView_collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(15, 20, sCommonUnitFullWidth()-15, 14+2+4) collectionViewLayout:flowLayout];_collectionView.dataSource = self;_collectionView.delegate = self;_collectionView.showsHorizontalScrollIndicator = NO;_collectionView.showsVerticalScrollIndicator = NO;_collectionView.alwaysBounceVertical = NO;if (@available(iOS 11.0, *)) {_collectionView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;}_collectionView.backgroundColor = [UIColor whiteColor];//RGBA(246, 246, 246, 1);//BGColorHex(F9F9F9);[_collectionView registerClass:[UICollectionReusableView class] forSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"lineFootView"];[_collectionView registerClass:[BGCateToolCollectionCell class] forCellWithReuseIdentifier:NSStringFromClass([BGCateToolCollectionCell class])];//定义每个UICollectionView 的大小flowLayout.itemSize = CGSizeMake(80 , 20);//定义每个UICollectionView 横向的间距flowLayout.minimumLineSpacing = BG_1PX;//定义每个UICollectionView 纵向的间距flowLayout.minimumInteritemSpacing = BG_1PX;flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal;//定义每个UICollectionView 的边距距// flowLayout.sectionInset = UIEdgeInsetsMake(5, 5, 5, 5);//上左下}return _collectionView;
}//两个cell之间的间距(同一行的cell的间距)- (CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumInteritemSpacingForSectionAtIndex:(NSInteger)section
{return BG_1PX;
}//这个是两行cell之间的间距(上下行cell的间距
-(CGFloat)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout minimumLineSpacingForSectionAtIndex:(NSInteger)section
{return BG_1PX;
}- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{BGCateToolCollectionCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:NSStringFromClass([BGCateToolCollectionCell class]) forIndexPath:indexPath];[cell updateWithSelectCateToolUnitEntity:self.selectCateToolUnitEntity model:[self.model.cate_list bitobjectOrNilAtIndex:indexPath.row]];return cell;
}- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section{return self.model.cate_list.count;
}- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{return isCommonUnitEmptyArray(self.model.cate_list) ? 0 : self.model.cate_list.count;
}-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{self.selectCateToolUnitEntity = [self.model.cate_list bitobjectOrNilAtIndex:indexPath.row];if(self.selectCateToolUnitEntity && [self.selectCateToolUnitEntity isKindOfClass:[BGCateToolUnitEntity class]] && self.selectBlock){self.selectBlock(self.selectCateToolUnitEntity);[self.collectionView reloadData];}
}- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath *)indexPath {return CGSizeMake(80, 20);
}//- (CGSize)collectionView:(UICollectionView *)collectionView layout:(UICollectionViewLayout*)collectionViewLayout referenceSizeForHeaderInSection:(NSInteger)section {// return CGSizeMake(FULL_WIDTH, BG_1PX);
//}创建头视图
//- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
//{// if (self.lineFootView)
// {// return self.lineFootView;
// }
//
// UICollectionReusableView *lineFootView = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader
// withReuseIdentifier:@"lineFootView" forIndexPath:indexPath];
// self.lineFootView = lineFootView;
// UIView *lineFootViewPanel = [[UIView alloc] initWithFrame:CGRectMake(0, 0, FULL_WIDTH, BG_1PX)];
// lineFootViewPanel.backgroundColor = [UIColor clearColor];
// [lineFootView addSubview:lineFootViewPanel];
// return lineFootView;
//}//- (BGCateToolEntity *)model {// if(!_model)
// {// _model = [[BGCateToolEntity alloc] init];
// }
// return _model;
//}//- (void)updateWithSelectCateToolUnitEntity:(BGCateToolUnitEntity *)selectCateToolUnitEntity model:(BGCateToolEntity *)model
//{// self.selectCateToolUnitEntity = selectCateToolUnitEntity;
// self.model = model;
//}-(void)setModel:(BGCateToolEntity *)model
{if(!model || ![model isKindOfClass:[BGCateToolEntity class]]){return;}_model = model;self.selectCateToolUnitEntity = [self.model.cate_list bitobjectOrNilAtIndex:0];[self.collectionView reloadData];
}@end
BGCateToolCollectionCell.h
#import <UIKit/UIKit.h>
#import "PPCollectionViewCell.h"
//#import "BGCalendarMacro.h"
//#import "BGCalendarEntity.h"
#import "BGCateToolUnitEntity.h"@interface BGCateToolCollectionCell : PPCollectionViewCell
@property (nonatomic, strong) UILabel *describeTitleLabel;
@property (nonatomic, strong) UIView *lineView;
@property (nonatomic, strong) BGCateToolUnitEntity *model;
@property (nonatomic, assign) BOOL isHiddenLine;- (instancetype)initWithFrame:(CGRect)frame;- (void)updateWithSelectCateToolUnitEntity:(BGCateToolUnitEntity *)selectCateToolUnitEntity model:(BGCateToolUnitEntity *)model;@end
BGCateToolCollectionCell.m
#import "BGCateToolCollectionCell.h"@interface BGCateToolCollectionCell ()
@property (nonatomic, strong) UIView *bigBackgroundView;@end@implementation BGCateToolCollectionCell-(instancetype)initWithFrame:(CGRect)frame{self = [super initWithFrame:frame];if (self) {[self setupViewWithFrame:frame];}return self;}-(void)setupViewWithFrame:(CGRect)frame
{self.bigBackgroundView = [[UIView alloc] init];self.bigBackgroundView.backgroundColor = [UIColor whiteColor];[self.contentView addSubview:self.bigBackgroundView];[self.bigBackgroundView addSubview:self.describeTitleLabel];[self.bigBackgroundView addSubview:self.lineView];[self unitsSdLayout];
}- (void)updateWithSelectCateToolUnitEntity:(BGCateToolUnitEntity *)selectCateToolUnitEntity model:(BGCateToolUnitEntity *)model
{if((!selectCateToolUnitEntity || ![selectCateToolUnitEntity isKindOfClass:[BGCateToolUnitEntity class]]) || (!model || ![model isKindOfClass:[BGCateToolUnitEntity class]]) || (selectCateToolUnitEntity != model) || isCommonUnitEmptyString(selectCateToolUnitEntity.cate_id)){self.isHiddenLine = YES;self.model = model;}else{self.isHiddenLine = NO;self.model = model;}
}-(void)setIsHiddenLine:(BOOL)isHiddenLine
{self.lineView.hidden = isHiddenLine;_isHiddenLine = isHiddenLine;
}-(void)setModel:(BGCateToolUnitEntity *)model
{if(!model || ![model isKindOfClass:[BGCateToolUnitEntity class]]){return;}self.describeTitleLabel.text = getNotNilString(model.name);[self.describeTitleLabel updateLayout];if(!self.isHiddenLine){[self.lineView updateLayout];}_model = model;
}-(void)unitsSdLayout
{self.bigBackgroundView.sd_layout.topSpaceToView(self.contentView, 0).rightSpaceToView(self.contentView, 0).widthIs(self.frame.size.width).heightIs(self.frame.size.height);self.describeTitleLabel.sd_layout.topSpaceToView(self.bigBackgroundView, 0).leftSpaceToView(self.bigBackgroundView, 0).heightIs(14);[self.describeTitleLabel setSingleLineAutoResizeWithMaxWidth:80];self.lineView.sd_layout.topSpaceToView(self.describeTitleLabel, 4).centerXEqualToView(self.describeTitleLabel).widthIs(40).heightIs(2);
}- (UIView *)lineView {if(!_lineView){_lineView = [[UIView alloc] init];_lineView.backgroundColor = BGColorHex(FF7648);_lineView.hidden = YES;}return _lineView;
}- (UILabel *)describeTitleLabel {if(!_describeTitleLabel){_describeTitleLabel = [[UILabel alloc] init];_describeTitleLabel.backgroundColor = [UIColor whiteColor];_describeTitleLabel.textAlignment = NSTextAlignmentLeft;_describeTitleLabel.font = BGFont(14);_describeTitleLabel.numberOfLines = 1;_describeTitleLabel.textColor = COMMON_FONT_COLOR;_describeTitleLabel.text = @"教学用品";}return _describeTitleLabel;
}@end
BGCalendarMacro.h
#ifndef BGCalendar_Macro_h
#define BGCalendar_Macro_h#define sCalendarCellInterval 7.5#endif
BGCalendarUnitEntity.h
#import <Foundation/Foundation.h>@interface BGCalendarUnitEntity : BGBaseEntity
//@property (nonatomic, assign) NSInteger section;
@property (nonatomic, assign) NSInteger row;
@property (nonatomic, assign) BOOL isSelect;@property (nonatomic, strong) NSString *value;
@property (nonatomic, strong) NSString *weekName;
@property (nonatomic, assign) long long weekdayIndex;
@property (nonatomic, assign) long long timeStamp;
@property (nonatomic, assign) BOOL isShowToday;@property (nonatomic, assign) NSUInteger year;
@property (nonatomic, assign) NSUInteger month;
@property (nonatomic, assign) NSUInteger day;
@property (nonatomic, strong) NSString *yearMonth;@property (nonatomic, assign) long long intervalGMT;@property (nonatomic, assign) long long monthCount;@end
#import “BGCalendarUnitEntity.h”
#import "BGCalendarUnitEntity.h"@implementation BGCalendarUnitEntity- (id)init
{if (self){self.value = nil;}return self;
}-(void)fillData
{}@end
左右可以滑动半年的超级日历,支持日历部分收起和自动重定向为北京时间相关推荐
- 纵享丝滑滑动切换的周月日历,可流畅滑动高度定制,仿小米日历,基于 material-calendarview
monthweekmaterialcalendarview 项目地址:idic779/monthweekmaterialcalendarview 简介:纵享丝滑滑动切换的周月日历,可流畅滑动高度定制 ...
- asp前端日历_asp日历-和asp日历相关的内容-阿里云开发者社区
ASP.NET MVC中加载WebForms用户控件(.ascx) 原文:ASP.NET MVC中加载WebForms用户控件(.ascx) 问题背景 博客园博客中的日历用的是ASP.NET WebF ...
- android 最简洁的日历,简洁日历 - 日历与 ToDo 的完美结合 #Android
原标题:简洁日历 - 日历与 ToDo 的完美结合 #Android 日历行程应用一向都是非常轻量的,甚至有时候略显单调.毕竟对于此类应用大多数时候我们仅仅将之视为获取即时信息的工具,所以大部分朋友会 ...
- Outlook怎么打印日历 Outlook日历打印教程
Outlook中的日历想要打印出来,该怎么打印日历呢?下面我们就来看看详细的教程. Outlook怎么打印日历? Outlook日历打印教程 1.下载安装outlook软件. Outlook怎么打印日 ...
- LiveGBS国标GB/T28181视频流媒体平台云端录像配置开启关闭支持录像计划根据计划自动录制
LiveGBS国标GB/T28181视频流媒体平台云端录像配置开启关闭支持录像计划根据计划自动录制 1.云端录像说明 2.手动配置录像 2.1.按需云端录像-用户播放摄像机时录像 2.2.云端一直录像 ...
- python日历函数_Python—日历函数—日历模块的常用函数,calendar,常见
Python-日历函数-日历模块的常用函数,calendar,常见 发表时间:2020-07-07 日历函数 calendar模块中提供了非常多的函数来处理年历和日历. 例如:打印2020年7月份的日 ...
- 前端日历,vue日历,一周的日历
点击这个看看vue的,下面的很多bug坑点击gitee有详细的代码 仿掘金活动日历 js日历 web日历 jQuery日历 需要用到jQuery 重要的在于 'var firstDay = (new ...
- Discuz!论坛教程之设置帖子被支持/反对(顶/踩)后自动提升主题
本文介绍一种在帖子被用户支持/反对(顶/踩)后自动提升的方法: 修改文件: \source\module\forum\forum_misc.php 修改方法: 搜索 if($_G['setting'] ...
- 日历2019日历备注_如何在Windows 10日历应用中使用Google日历
日历2019日历备注 With the arrival of Windows 10, we've been greeted with a new slew of functionality-based ...
最新文章
- NOI2012 美食节
- 成功搞定了在Windows7中安装SAP了
- 开发中遇到的问题,以及笔记
- 深度学习语音降噪方法对比_人工智能-关于深度学习的基础方法
- mardown文件图片技巧
- 关于积累-accumulation
- Uboot启动全过程
- python程序开发正则表达式_python正则表达式的使用(实验代码)
- 地砖中间高四边低_地砖上墙到底好不好?幸好我家没这么做否则全毁了!
- linux下mono的安装与卸载
- Markdown案例
- Mac:Split文件分割命令
- ZZ_MODIFIED_GEEBINF 不可用
- windows fromdatagrid双击行或者行的内容_一些提升windows办公,编写代码的神器 carnac,Total commander...
- Bailian4112 情报破译-Cryptanalysis【密码】
- Docker 的使用
- wordpress建立二级导航菜单
- JAVA生成pdf文件
- linux几个工具的安装
- 【Leetcode刷题篇】leetcode739 每日温度
热门文章
- 基于COMSOL的固体力学或压力声学模块仿真声子晶体
- java pgp加密_基于Java Bouncy Castle的PGP加密解密示例
- c语言结构体指针->基本使用
- Java项目ssm企业工资管理系统源码
- 使用git命令从gitlab下载项目
- 恒星物联-排水管网有害气体监测系统 有害气体监测
- 数学建模part (4):综合评价
- 计算机教案.doc免费,计算机应用基础教案98839.doc
- 学生教育云平台登录入口_国家中小学网络云平台登录入口_国家中小学网络云平台...
- vue实现数字翻牌器组建,能够正常显示负数符号