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

Added feature to set the font of the selected day in calendar #1397

Open
wants to merge 1 commit 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
5 changes: 5 additions & 0 deletions FSCalendar/FSCalendarAppearance.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ typedef NS_OPTIONS(NSUInteger, FSCalendarCaseOptions) {
*/
@property (strong, nonatomic) UIFont *titleFont;

/**
* The font of the selected day text.
*/
@property (strong, nonatomic) UIFont *titleSelectedFont;

/**
* The font of the subtitle text.
*/
Expand Down
9 changes: 9 additions & 0 deletions FSCalendar/FSCalendarAppearance.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ - (instancetype)init
if (self) {

_titleFont = [UIFont systemFontOfSize:FSCalendarStandardTitleTextSize];
_titleSelectedFont = [UIFont systemFontOfSize:FSCalendarStandardSelectedTitleTextSize];
_subtitleFont = [UIFont systemFontOfSize:FSCalendarStandardSubtitleTextSize];
_weekdayFont = [UIFont systemFontOfSize:FSCalendarStandardWeekdayTextSize];
_headerTitleFont = [UIFont systemFontOfSize:FSCalendarStandardHeaderTextSize];
Expand Down Expand Up @@ -90,6 +91,14 @@ - (void)setTitleFont:(UIFont *)titleFont
}
}

- (void)setTitleSelectionFont:(UIFont *)titleSelectedFont
{
if (![_titleSelectedFont isEqual:titleSelectedFont]) {
_titleSelectedFont = titleSelectedFont;
[self.calendar configureAppearance];
}
}

- (void)setSubtitleFont:(UIFont *)subtitleFont
{
if (![_subtitleFont isEqual:subtitleFont]) {
Expand Down
9 changes: 9 additions & 0 deletions FSCalendar/FSCalendarCell.m
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,19 @@ - (void)configureAppearance
- (UIColor *)colorForCurrentStateInDictionary:(NSDictionary *)dictionary
{
if (self.isSelected) {
UIFont *titleSelectedFont = self.calendar.appearance.titleSelectedFont;
if (![titleSelectedFont isEqual:_titleLabel.font]) {
_titleLabel.font = titleSelectedFont;
}
if (self.dateIsToday) {
return dictionary[@(FSCalendarCellStateSelected|FSCalendarCellStateToday)] ?: dictionary[@(FSCalendarCellStateSelected)];
}
return dictionary[@(FSCalendarCellStateSelected)];
} else {
UIFont *titleFont = self.calendar.appearance.titleFont;
if (![titleFont isEqual:_titleLabel.font]) {
_titleLabel.font = titleFont;
}
}
if (self.dateIsToday && [[dictionary allKeys] containsObject:@(FSCalendarCellStateToday)]) {
return dictionary[@(FSCalendarCellStateToday)];
Expand Down
1 change: 1 addition & 0 deletions FSCalendar/FSCalendarConstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ CG_EXTERN CGFloat const FSCalendarAutomaticDimension;
CG_EXTERN CGFloat const FSCalendarDefaultBounceAnimationDuration;
CG_EXTERN CGFloat const FSCalendarStandardRowHeight;
CG_EXTERN CGFloat const FSCalendarStandardTitleTextSize;
CG_EXTERN CGFloat const FSCalendarStandardSelectedTitleTextSize;
CG_EXTERN CGFloat const FSCalendarStandardSubtitleTextSize;
CG_EXTERN CGFloat const FSCalendarStandardWeekdayTextSize;
CG_EXTERN CGFloat const FSCalendarStandardHeaderTextSize;
Expand Down
1 change: 1 addition & 0 deletions FSCalendar/FSCalendarConstants.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
CGFloat const FSCalendarDefaultBounceAnimationDuration = 0.15;
CGFloat const FSCalendarStandardRowHeight = 38;
CGFloat const FSCalendarStandardTitleTextSize = 13.5;
CGFloat const FSCalendarStandardSelectedTitleTextSize = 13.5;
CGFloat const FSCalendarStandardSubtitleTextSize = 10;
CGFloat const FSCalendarStandardWeekdayTextSize = 14;
CGFloat const FSCalendarStandardHeaderTextSize = 16.5;
Expand Down