Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

新增未选中日期和非当前页面日期的背景颜色 #1380

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Example-Objc/FSCalendar.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,10 @@
30A495521DCAD9E6000B2F31 /* FSCalendarWeekdayView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSCalendarWeekdayView.h; sourceTree = "<group>"; };
30A495531DCAD9E6000B2F31 /* FSCalendarWeekdayView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FSCalendarWeekdayView.m; sourceTree = "<group>"; };
30B0BABF1B8D8E22004B9476 /* FSCalendar.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSCalendar.h; sourceTree = "<group>"; };
30B0BAC01B8D8E22004B9476 /* FSCalendar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = FSCalendar.m; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objc; };
30B0BAC01B8D8E22004B9476 /* FSCalendar.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = FSCalendar.m; sourceTree = "<group>"; };
30B0BAC11B8D8E22004B9476 /* FSCalendarAppearance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSCalendarAppearance.h; sourceTree = "<group>"; };
30B0BAC21B8D8E22004B9476 /* FSCalendarAppearance.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FSCalendarAppearance.m; sourceTree = "<group>"; };
30B0BAC31B8D8E22004B9476 /* FSCalendarCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = FSCalendarCell.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
30B0BAC31B8D8E22004B9476 /* FSCalendarCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = FSCalendarCell.h; sourceTree = "<group>"; };
30B0BAC41B8D8E22004B9476 /* FSCalendarCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FSCalendarCell.m; sourceTree = "<group>"; };
30B0BAC51B8D8E22004B9476 /* FSCalendarDynamicHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSCalendarDynamicHeader.h; sourceTree = "<group>"; };
30B0BAC61B8D8E22004B9476 /* FSCalendarHeaderView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FSCalendarHeaderView.h; sourceTree = "<group>"; };
Expand Down
5 changes: 5 additions & 0 deletions FSCalendar/FSCalendar.h
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,11 @@ IB_DESIGNABLE
*/
@property (nullable, readonly, nonatomic) NSDate *selectedDate;

/**
A date for publisher
*/
@property (nullable, nonatomic) NSDate *addedDate;

/**
The dates representing the selected dates. (read-only)
*/
Expand Down
1 change: 1 addition & 0 deletions FSCalendar/FSCalendar.m
Original file line number Diff line number Diff line change
Expand Up @@ -1485,6 +1485,7 @@ - (void)deselectCounterpartDate:(NSDate *)date

- (void)enqueueSelectedDate:(NSDate *)date
{
self.addedDate = date;
if (!self.allowsMultipleSelection) {
[_selectedDates removeAllObjects];
}
Expand Down
15 changes: 15 additions & 0 deletions FSCalendar/FSCalendarAppearance.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ typedef NS_OPTIONS(NSUInteger, FSCalendarCaseOptions) {
*/
@property (assign, nonatomic) CGPoint imageOffset;

/**
* The background color of normal date.
*/
@property (assign, nonatomic) UIColor *normalColor;

/**
* The background color of placeholder date.
*/
@property (assign, nonatomic) UIColor *placeholderColor;

/**
* The color of event dots.
*/
Expand Down Expand Up @@ -199,6 +209,11 @@ typedef NS_OPTIONS(NSUInteger, FSCalendarCaseOptions) {
*/
@property (strong, nonatomic) UIColor *borderDefaultColor;

/**
* The border color of the shape for today.
*/
@property (strong, nonatomic) UIColor *borderTodayColor;

/**
* The border color of the shape for selected state.
*/
Expand Down
39 changes: 39 additions & 0 deletions FSCalendar/FSCalendarAppearance.m
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,32 @@ - (UIColor *)todaySelectionColor
return _backgroundColors[@(FSCalendarCellStateToday|FSCalendarCellStateSelected)];
}

- (void)setNormalColor:(UIColor *)normalColor {
if (normalColor) {
_backgroundColors[@(FSCalendarCellStateNormal)] = normalColor;
} else {
[_backgroundColors removeObjectForKey:@(FSCalendarCellStateNormal)];
}
[self.calendar configureAppearance];
}

- (UIColor *)normalColor {
return _backgroundColors[@(FSCalendarCellStateNormal)];
}

- (void)setPlaceholderColor:(UIColor *)placeholderColor {
if (placeholderColor) {
_backgroundColors[@(FSCalendarCellStatePlaceholder)] = placeholderColor;
} else {
[_backgroundColors removeObjectForKey:@(FSCalendarCellStatePlaceholder)];
}
[self.calendar configureAppearance];
}

- (UIColor *)placeholderColor {
return _backgroundColors[@(FSCalendarCellStatePlaceholder)];
}

- (void)setEventDefaultColor:(UIColor *)eventDefaultColor
{
if (![_eventDefaultColor isEqual:eventDefaultColor]) {
Expand All @@ -371,6 +397,19 @@ - (UIColor *)borderDefaultColor
return _borderColors[@(FSCalendarCellStateNormal)];
}

- (void)setBorderTodayColor:(UIColor *)color {
if (color) {
_borderColors[@(FSCalendarCellStateToday)] = color;
} else {
[_borderColors removeObjectForKey:@(FSCalendarCellStateToday)];
}
[self.calendar configureAppearance];
}

- (UIColor *)borderTodayColor {
return _borderColors[@(FSCalendarCellStateToday)];
}

- (void)setBorderSelectionColor:(UIColor *)color
{
if (color) {
Expand Down
2 changes: 1 addition & 1 deletion FSCalendar/FSCalendarCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ - (UIColor *)colorForCellBorder
if (self.selected) {
return _preferredBorderSelectionColor ?: _appearance.borderSelectionColor;
}
return _preferredBorderDefaultColor ?: _appearance.borderDefaultColor;
return [self colorForCurrentStateInDictionary:_appearance.borderColors] ?: _preferredBorderDefaultColor;
}

- (NSArray<UIColor *> *)colorsForEvents
Expand Down