FSCalendar日历选择器,
需求说明:
1.需自定义日历顶部,左右小按钮可点击切换月份
2.当天文字颜色为主色调,选中为含有背景色
3.日历样式只显示当月时间
4.周六、周日文字与其他日期颜色不同
5.点击已过去的时间不可创建
先上界面
//
// XYCalendarTableViewCell.h
//
// Created by [email protected] on 2020/1/14.
// Copyright © 2020 xy. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <FSCalendar.h>
NS_ASSUME_NONNULL_BEGIN
@interface XYCalendarTableViewCell : UITableViewCell <FSCalendarDelegateAppearance,FSCalendarDelegate,FSCalendarDataSource>
@property (weak, nonatomic) IBOutlet FSCalendar *calendar;
@property (weak, nonatomic) IBOutlet UIButton *contentBut;//xxxx年xx月
@property (nonatomic, strong) NSCalendar *chineseCalendar;//系统日历
@property (nonatomic, strong) NSDateFormatter *formatter;
// 时间戳传递出去
@property (nonatomic, copy) void(^CalendarClickBlock)(BOOL compareResult,NSInteger timestamp);
@end
NS_ASSUME_NONNULL_END
//
// XYCalendarTableViewCell.m
// yishopformerchants
//
// Created by [email protected] on 2020/1/14.
// Copyright © 2020 xy. All rights reserved.
//
#import "XYCalendarTableViewCell.h"
@implementation XYCalendarTableViewCell
- (void)awakeFromNib {
[super awakeFromNib];
// Initialization code
self.selectionStyle = UITableViewCellSelectionStyleNone;
// 设置日历格式为公历
self.chineseCalendar = [NSCalendar calendarWithIdentifier:NSCalendarIdentifierGregorian];
// 设置日历翻页
self.calendar.pagingEnabled =