Commit a4fd38ad authored by 刘俊宏's avatar 刘俊宏

完善日历选择器

parent 9d9d2a91
{
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wangnian.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wangnian@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wangnian@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "wangyue.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "wangyue@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "wangyue@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "xiageyue.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "xiageyue@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "xiageyue@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
{
"images" : [
{
"filename" : "xiayinian.png",
"idiom" : "universal",
"scale" : "1x"
},
{
"filename" : "xiayinian@2x.png",
"idiom" : "universal",
"scale" : "2x"
},
{
"filename" : "xiayinian@3x.png",
"idiom" : "universal",
"scale" : "3x"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
......@@ -11,5 +11,6 @@
#import "MJRefresh.h"
#import "WYHead.h"
#import "FSCalendar.h"
#endif /* Bridge_Header_h */
This diff is collapsed.
This diff is collapsed.
//
// FSCalendarAppearance.h
// Pods
//
// Created by DingWenchao on 6/29/15.
// Copyright © 2016 Wenchao Ding. All rights reserved.
//
// https://github.com/WenchaoD
//
#import "FSCalendarConstants.h"
@class FSCalendar;
typedef NS_ENUM(NSInteger, FSCalendarCellState) {
FSCalendarCellStateNormal = 0,
FSCalendarCellStateSelected = 1,
FSCalendarCellStatePlaceholder = 1 << 1,
FSCalendarCellStateDisabled = 1 << 2,
FSCalendarCellStateToday = 1 << 3,
FSCalendarCellStateWeekend = 1 << 4,
FSCalendarCellStateTodaySelected = FSCalendarCellStateToday|FSCalendarCellStateSelected
};
typedef NS_ENUM(NSUInteger, FSCalendarSeparators) {
FSCalendarSeparatorNone = 0,
FSCalendarSeparatorInterRows = 1
};
typedef NS_OPTIONS(NSUInteger, FSCalendarCaseOptions) {
FSCalendarCaseOptionsHeaderUsesDefaultCase = 0,
FSCalendarCaseOptionsHeaderUsesUpperCase = 1,
FSCalendarCaseOptionsWeekdayUsesDefaultCase = 0 << 4,
FSCalendarCaseOptionsWeekdayUsesUpperCase = 1 << 4,
FSCalendarCaseOptionsWeekdayUsesSingleUpperCase = 2 << 4,
};
/**
* FSCalendarAppearance determines the fonts and colors of components in the calendar.
*
* @see FSCalendarDelegateAppearance
*/
@interface FSCalendarAppearance : NSObject
/**
* The font of the day text.
*/
@property (strong, nonatomic) UIFont *titleFont;
/**
* The font of the subtitle text.
*/
@property (strong, nonatomic) UIFont *subtitleFont;
/**
* The font of the weekday text.
*/
@property (strong, nonatomic) UIFont *weekdayFont;
/**
* The font of the month text.
*/
@property (strong, nonatomic) UIFont *headerTitleFont;
/**
* The offset of the day text from default position.
*/
@property (assign, nonatomic) CGPoint titleOffset;
/**
* The offset of the day text from default position.
*/
@property (assign, nonatomic) CGPoint subtitleOffset;
/**
* The offset of the event dots from default position.
*/
@property (assign, nonatomic) CGPoint eventOffset;
/**
* The offset of the image from default position.
*/
@property (assign, nonatomic) CGPoint imageOffset;
/**
* The color of event dots.
*/
@property (strong, nonatomic) UIColor *eventDefaultColor;
/**
* The color of event dots.
*/
@property (strong, nonatomic) UIColor *eventSelectionColor;
/**
* The color of weekday text.
*/
@property (strong, nonatomic) UIColor *weekdayTextColor;
/**
* The color of month header text.
*/
@property (strong, nonatomic) UIColor *headerTitleColor;
/**
* The date format of the month header.
*/
@property (strong, nonatomic) NSString *headerDateFormat;
/**
* The alpha value of month label staying on the fringes.
*/
@property (assign, nonatomic) CGFloat headerMinimumDissolvedAlpha;
/**
* The day text color for unselected state.
*/
@property (strong, nonatomic) UIColor *titleDefaultColor;
/**
* The day text color for selected state.
*/
@property (strong, nonatomic) UIColor *titleSelectionColor;
/**
* The day text color for today in the calendar.
*/
@property (strong, nonatomic) UIColor *titleTodayColor;
/**
* The day text color for days out of current month.
*/
@property (strong, nonatomic) UIColor *titlePlaceholderColor;
/**
* The day text color for weekend.
*/
@property (strong, nonatomic) UIColor *titleWeekendColor;
/**
* The subtitle text color for unselected state.
*/
@property (strong, nonatomic) UIColor *subtitleDefaultColor;
/**
* The subtitle text color for selected state.
*/
@property (strong, nonatomic) UIColor *subtitleSelectionColor;
/**
* The subtitle text color for today in the calendar.
*/
@property (strong, nonatomic) UIColor *subtitleTodayColor;
/**
* The subtitle text color for days out of current month.
*/
@property (strong, nonatomic) UIColor *subtitlePlaceholderColor;
/**
* The subtitle text color for weekend.
*/
@property (strong, nonatomic) UIColor *subtitleWeekendColor;
/**
* The fill color of the shape for selected state.
*/
@property (strong, nonatomic) UIColor *selectionColor;
/**
* The fill color of the shape for today.
*/
@property (strong, nonatomic) UIColor *todayColor;
/**
* The fill color of the shape for today and selected state.
*/
@property (strong, nonatomic) UIColor *todaySelectionColor;
/**
* The border color of the shape for unselected state.
*/
@property (strong, nonatomic) UIColor *borderDefaultColor;
/**
* The border color of the shape for selected state.
*/
@property (strong, nonatomic) UIColor *borderSelectionColor;
/**
* The border radius, while 1 means a circle, 0 means a rectangle, and the middle value will give it a corner radius.
*/
@property (assign, nonatomic) CGFloat borderRadius;
/**
* The case options manage the case of month label and weekday symbols.
*
* @see FSCalendarCaseOptions
*/
@property (assign, nonatomic) FSCalendarCaseOptions caseOptions;
/**
* The line integrations for calendar.
*
*/
@property (assign, nonatomic) FSCalendarSeparators separators;
@property (assign, nonatomic) BOOL useVeryShortWeekdaySymbols;
#if TARGET_INTERFACE_BUILDER
// For preview only
@property (assign, nonatomic) BOOL fakeSubtitles;
@property (assign, nonatomic) BOOL fakeEventDots;
@property (assign, nonatomic) NSInteger fakedSelectedDay;
#endif
@end
//
// FSCalendarCalculator.h
// FSCalendar
//
// Created by dingwenchao on 30/10/2016.
// Copyright © 2016 Wenchao Ding. All rights reserved.
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
struct FSCalendarCoordinate {
NSInteger row;
NSInteger column;
};
typedef struct FSCalendarCoordinate FSCalendarCoordinate;
@interface FSCalendarCalculator : NSObject
@property (weak , nonatomic) FSCalendar *calendar;
@property (readonly, nonatomic) NSInteger numberOfSections;
- (instancetype)initWithCalendar:(FSCalendar *)calendar;
- (NSDate *)safeDateForDate:(NSDate *)date;
- (NSDate *)dateForIndexPath:(NSIndexPath *)indexPath;
- (NSDate *)dateForIndexPath:(NSIndexPath *)indexPath scope:(FSCalendarScope)scope;
- (NSIndexPath *)indexPathForDate:(NSDate *)date;
- (NSIndexPath *)indexPathForDate:(NSDate *)date scope:(FSCalendarScope)scope;
- (NSIndexPath *)indexPathForDate:(NSDate *)date atMonthPosition:(FSCalendarMonthPosition)position;
- (NSIndexPath *)indexPathForDate:(NSDate *)date atMonthPosition:(FSCalendarMonthPosition)position scope:(FSCalendarScope)scope;
- (NSDate *)pageForSection:(NSInteger)section;
- (NSDate *)weekForSection:(NSInteger)section;
- (NSDate *)monthForSection:(NSInteger)section;
- (NSDate *)monthHeadForSection:(NSInteger)section;
- (NSInteger)numberOfHeadPlaceholdersForMonth:(NSDate *)month;
- (NSInteger)numberOfRowsInMonth:(NSDate *)month;
- (NSInteger)numberOfRowsInSection:(NSInteger)section;
- (FSCalendarMonthPosition)monthPositionForIndexPath:(NSIndexPath *)indexPath;
- (FSCalendarCoordinate)coordinateForIndexPath:(NSIndexPath *)indexPath;
- (void)reloadSections;
@end
//
// FSCalendarCell.h
// Pods
//
// Created by Wenchao Ding on 12/3/15.
//
//
#import <UIKit/UIKit.h>
@class FSCalendar, FSCalendarAppearance, FSCalendarEventIndicator;
typedef NS_ENUM(NSUInteger, FSCalendarMonthPosition);
@interface FSCalendarCell : UICollectionViewCell
#pragma mark - Public properties
/**
The day text label of the cell
*/
@property (weak, nonatomic) UILabel *titleLabel;
/**
The subtitle label of the cell
*/
@property (weak, nonatomic) UILabel *subtitleLabel;
/**
The shape layer of the cell
*/
@property (weak, nonatomic) CAShapeLayer *shapeLayer;
/**
The imageView below shape layer of the cell
*/
@property (weak, nonatomic) UIImageView *imageView;
/**
The collection of event dots of the cell
*/
@property (weak, nonatomic) FSCalendarEventIndicator *eventIndicator;
/**
A boolean value indicates that whether the cell is "placeholder". Default is NO.
*/
@property (assign, nonatomic, getter=isPlaceholder) BOOL placeholder;
#pragma mark - Private properties
@property (weak, nonatomic) FSCalendar *calendar;
@property (weak, nonatomic) FSCalendarAppearance *appearance;
@property (strong, nonatomic) NSString *subtitle;
@property (strong, nonatomic) UIImage *image;
@property (assign, nonatomic) FSCalendarMonthPosition monthPosition;
@property (assign, nonatomic) NSInteger numberOfEvents;
@property (assign, nonatomic) BOOL dateIsToday;
@property (assign, nonatomic) BOOL weekend;
@property (strong, nonatomic) UIColor *preferredFillDefaultColor;
@property (strong, nonatomic) UIColor *preferredFillSelectionColor;
@property (strong, nonatomic) UIColor *preferredTitleDefaultColor;
@property (strong, nonatomic) UIColor *preferredTitleSelectionColor;
@property (strong, nonatomic) UIColor *preferredSubtitleDefaultColor;
@property (strong, nonatomic) UIColor *preferredSubtitleSelectionColor;
@property (strong, nonatomic) UIColor *preferredBorderDefaultColor;
@property (strong, nonatomic) UIColor *preferredBorderSelectionColor;
@property (assign, nonatomic) CGPoint preferredTitleOffset;
@property (assign, nonatomic) CGPoint preferredSubtitleOffset;
@property (assign, nonatomic) CGPoint preferredImageOffset;
@property (assign, nonatomic) CGPoint preferredEventOffset;
@property (strong, nonatomic) NSArray<UIColor *> *preferredEventDefaultColors;
@property (strong, nonatomic) NSArray<UIColor *> *preferredEventSelectionColors;
@property (assign, nonatomic) CGFloat preferredBorderRadius;
// Add subviews to self.contentView and set up constraints
- (instancetype)initWithFrame:(CGRect)frame NS_REQUIRES_SUPER;
- (instancetype)initWithCoder:(NSCoder *)aDecoder NS_REQUIRES_SUPER;
// For DIY overridden
- (void)layoutSubviews NS_REQUIRES_SUPER; // Configure frames of subviews
- (void)configureAppearance NS_REQUIRES_SUPER; // Configure appearance for cell
- (UIColor *)colorForCurrentStateInDictionary:(NSDictionary *)dictionary;
- (void)performSelecting;
@end
@interface FSCalendarEventIndicator : UIView
@property (assign, nonatomic) NSInteger numberOfEvents;
@property (strong, nonatomic) id color;
@end
@interface FSCalendarBlankCell : UICollectionViewCell
- (void)configureAppearance;
@end
This diff is collapsed.
//
// FSCalendarCollectionView.h
// FSCalendar
//
// Created by Wenchao Ding on 10/25/15.
// Copyright (c) 2015 Wenchao Ding. All rights reserved.
//
#import <UIKit/UIKit.h>
@class FSCalendarCollectionView;
@protocol FSCalendarCollectionViewInternalDelegate <UICollectionViewDelegate>
@optional
- (void)collectionViewDidFinishLayoutSubviews:(FSCalendarCollectionView *)collectionView;
@end
@interface FSCalendarCollectionView : UICollectionView
@property (weak, nonatomic) id<FSCalendarCollectionViewInternalDelegate> internalDelegate;
@end
//
// FSCalendarCollectionView.m
// FSCalendar
//
// Created by Wenchao Ding on 10/25/15.
// Copyright (c) 2015 Wenchao Ding. All rights reserved.
//
// Reject -[UIScrollView(UIScrollViewInternal) _adjustContentOffsetIfNecessary]
#import "FSCalendarCollectionView.h"
#import "FSCalendarExtensions.h"
#import "FSCalendarConstants.h"
@interface FSCalendarCollectionView ()
- (void)commonInit;
@end
@implementation FSCalendarCollectionView
@synthesize scrollsToTop = _scrollsToTop, contentInset = _contentInset;
- (instancetype)initWithFrame:(CGRect)frame collectionViewLayout:(UICollectionViewLayout *)layout
{
self = [super initWithFrame:frame collectionViewLayout:layout];
if (self) {
[self commonInit];
}
return self;
}
- (instancetype)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
[self commonInit];
}
return self;
}
- (void)commonInit
{
self.scrollsToTop = NO;
self.contentInset = UIEdgeInsetsZero;
if (@available(iOS 10.0, *)) self.prefetchingEnabled = NO;
if (@available(iOS 11.0, *)) self.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
- (void)layoutSubviews
{
[super layoutSubviews];
if (self.internalDelegate && [self.internalDelegate respondsToSelector:@selector(collectionViewDidFinishLayoutSubviews:)]) {
[self.internalDelegate collectionViewDidFinishLayoutSubviews:self];
}
}
- (void)setContentInset:(UIEdgeInsets)contentInset
{
[super setContentInset:UIEdgeInsetsZero];
if (contentInset.top) {
self.contentOffset = CGPointMake(self.contentOffset.x, self.contentOffset.y+contentInset.top);
}
}
- (void)setScrollsToTop:(BOOL)scrollsToTop
{
[super setScrollsToTop:NO];
}
@end
//
// FSCalendarAnimationLayout.h
// FSCalendar
//
// Created by dingwenchao on 1/3/16.
// Copyright © 2016 Wenchao Ding. All rights reserved.
//
#import <UIKit/UIKit.h>
@class FSCalendar;
@interface FSCalendarCollectionViewLayout : UICollectionViewLayout
@property (weak, nonatomic) FSCalendar *calendar;
@property (assign, nonatomic) UIEdgeInsets sectionInsets;
@property (assign, nonatomic) UICollectionViewScrollDirection scrollDirection;
@end
//
// FSCalendarConstane.h
// FSCalendar
//
// Created by dingwenchao on 8/28/15.
// Copyright © 2016 Wenchao Ding. All rights reserved.
//
// https://github.com/WenchaoD
//
#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>
#pragma mark - Constants
CG_EXTERN CGFloat const FSCalendarStandardHeaderHeight;
CG_EXTERN CGFloat const FSCalendarStandardWeekdayHeight;
CG_EXTERN CGFloat const FSCalendarStandardMonthlyPageHeight;
CG_EXTERN CGFloat const FSCalendarStandardWeeklyPageHeight;
CG_EXTERN CGFloat const FSCalendarStandardCellDiameter;
CG_EXTERN CGFloat const FSCalendarStandardSeparatorThickness;
CG_EXTERN CGFloat const FSCalendarAutomaticDimension;
CG_EXTERN CGFloat const FSCalendarDefaultBounceAnimationDuration;
CG_EXTERN CGFloat const FSCalendarStandardRowHeight;
CG_EXTERN CGFloat const FSCalendarStandardTitleTextSize;
CG_EXTERN CGFloat const FSCalendarStandardSubtitleTextSize;
CG_EXTERN CGFloat const FSCalendarStandardWeekdayTextSize;
CG_EXTERN CGFloat const FSCalendarStandardHeaderTextSize;
CG_EXTERN CGFloat const FSCalendarMaximumEventDotDiameter;
UIKIT_EXTERN NSInteger const FSCalendarDefaultHourComponent;
UIKIT_EXTERN NSInteger const FSCalendarMaximumNumberOfEvents;
UIKIT_EXTERN NSString * const FSCalendarDefaultCellReuseIdentifier;
UIKIT_EXTERN NSString * const FSCalendarBlankCellReuseIdentifier;
UIKIT_EXTERN NSString * const FSCalendarInvalidArgumentsExceptionName;
CG_EXTERN CGPoint const CGPointInfinity;
CG_EXTERN CGSize const CGSizeAutomatic;
#if TARGET_INTERFACE_BUILDER
#define FSCalendarDeviceIsIPad NO
#else
#define FSCalendarDeviceIsIPad [[UIDevice currentDevice].model hasPrefix:@"iPad"]
#endif
#define FSCalendarStandardSelectionColor FSColorRGBA(31,119,219,1.0)
#define FSCalendarStandardTodayColor FSColorRGBA(198,51,42 ,1.0)
#define FSCalendarStandardTitleTextColor FSColorRGBA(14,69,221 ,1.0)
#define FSCalendarStandardEventDotColor FSColorRGBA(31,119,219,0.75)
#define FSCalendarStandardLineColor [[UIColor lightGrayColor] colorWithAlphaComponent:0.30]
#define FSCalendarStandardSeparatorColor [[UIColor lightGrayColor] colorWithAlphaComponent:0.60]
#define FSColorRGBA(r,g,b,a) [UIColor colorWithRed:r/255.0 green:g/255.0 blue:b/255.0 alpha:a]
#define FSCalendarInAppExtension [[[NSBundle mainBundle] bundlePath] hasSuffix:@".appex"]
#define FSCalendarFloor(c) floorf(c)
#define FSCalendarRound(c) roundf(c)
#define FSCalendarCeil(c) ceilf(c)
#define FSCalendarMod(c1,c2) fmodf(c1,c2)
#define FSCalendarHalfRound(c) (FSCalendarRound(c*2)*0.5)
#define FSCalendarHalfFloor(c) (FSCalendarFloor(c*2)*0.5)
#define FSCalendarHalfCeil(c) (FSCalendarCeil(c*2)*0.5)
#define FSCalendarUseWeakSelf __weak __typeof__(self) FSCalendarWeakSelf = self;
#define FSCalendarUseStrongSelf __strong __typeof__(self) self = FSCalendarWeakSelf;
#pragma mark - Deprecated
#define FSCalendarDeprecated(instead) DEPRECATED_MSG_ATTRIBUTE(" Use " # instead " instead")
static inline void FSCalendarSliceCake(CGFloat cake, NSInteger count, CGFloat *pieces) {
CGFloat total = cake;
for (int i = 0; i < count; i++) {
NSInteger remains = count - i;
CGFloat piece = FSCalendarRound(total/remains*2)*0.5;
total -= piece;
pieces[i] = piece;
}
}
//
// FSCalendarConstane.m
// FSCalendar
//
// Created by dingwenchao on 8/28/15.
// Copyright © 2016 Wenchao Ding. All rights reserved.
//
// https://github.com/WenchaoD
//
#import "FSCalendarConstants.h"
CGFloat const FSCalendarStandardHeaderHeight = 40;
CGFloat const FSCalendarStandardWeekdayHeight = 25;
CGFloat const FSCalendarStandardMonthlyPageHeight = 300.0;
CGFloat const FSCalendarStandardWeeklyPageHeight = 108+1/3.0;
CGFloat const FSCalendarStandardCellDiameter = 100/3.0;
CGFloat const FSCalendarStandardSeparatorThickness = 0.5;
CGFloat const FSCalendarAutomaticDimension = -1;
CGFloat const FSCalendarDefaultBounceAnimationDuration = 0.15;
CGFloat const FSCalendarStandardRowHeight = 38;
CGFloat const FSCalendarStandardTitleTextSize = 13.5;
CGFloat const FSCalendarStandardSubtitleTextSize = 10;
CGFloat const FSCalendarStandardWeekdayTextSize = 14;
CGFloat const FSCalendarStandardHeaderTextSize = 16.5;
CGFloat const FSCalendarMaximumEventDotDiameter = 4.8;
NSInteger const FSCalendarDefaultHourComponent = 0;
NSInteger const FSCalendarMaximumNumberOfEvents = 3;
NSString * const FSCalendarDefaultCellReuseIdentifier = @"_FSCalendarDefaultCellReuseIdentifier";
NSString * const FSCalendarBlankCellReuseIdentifier = @"_FSCalendarBlankCellReuseIdentifier";
NSString * const FSCalendarInvalidArgumentsExceptionName = @"Invalid argument exception";
CGPoint const CGPointInfinity = {
.x = CGFLOAT_MAX,
.y = CGFLOAT_MAX
};
CGSize const CGSizeAutomatic = {
.width = FSCalendarAutomaticDimension,
.height = FSCalendarAutomaticDimension
};
//
// FSCalendarDelegationFactory.h
// FSCalendar
//
// Created by dingwenchao on 19/12/2016.
// Copyright © 2016 wenchaoios. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "FSCalendarDelegationProxy.h"
@interface FSCalendarDelegationFactory : NSObject
+ (FSCalendarDelegationProxy *)dataSourceProxy;
+ (FSCalendarDelegationProxy *)delegateProxy;
@end
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment