parent
511cfd6c84
commit
1df6ad5f69
|
|
@ -68,6 +68,11 @@
|
|||
|
||||
#pragma mark - FSCalendarDataSource
|
||||
|
||||
- (NSString *)calendar:(FSCalendar *)calendar titleForDate:(NSDate *)date
|
||||
{
|
||||
return [calendar isDateInToday:date] ? @"今天" : nil;
|
||||
}
|
||||
|
||||
- (NSString *)calendar:(FSCalendar *)calendar subtitleForDate:(NSDate *)date
|
||||
{
|
||||
if (!_lunar) {
|
||||
|
|
|
|||
|
|
@ -56,6 +56,11 @@ NS_ASSUME_NONNULL_BEGIN
|
|||
|
||||
@optional
|
||||
|
||||
/**
|
||||
* Asks the dataSource for a title for the specific date as a replacement of the day text
|
||||
*/
|
||||
- (nullable NSString *)calendar:(FSCalendar *)calendar titleForDate:(NSDate *)date;
|
||||
|
||||
/**
|
||||
* Asks the dataSource for a subtitle for the specific date under the day text.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ typedef NS_ENUM(NSUInteger, FSCalendarOrientation) {
|
|||
@interface FSCalendar (DataSourceAndDelegate)
|
||||
|
||||
- (NSInteger)numberOfEventsForDate:(NSDate *)date;
|
||||
- (NSString *)titleForDate:(NSDate *)date;
|
||||
- (NSString *)subtitleForDate:(NSDate *)date;
|
||||
- (UIImage *)imageForDate:(NSDate *)date;
|
||||
- (NSDate *)minimumDateForCalendar;
|
||||
|
|
@ -1577,6 +1578,7 @@ typedef NS_ENUM(NSUInteger, FSCalendarOrientation) {
|
|||
cell.date = [self dateForIndexPath:indexPath];
|
||||
cell.image = [self imageForDate:cell.date];
|
||||
cell.numberOfEvents = [self numberOfEventsForDate:cell.date];
|
||||
cell.title = [self titleForDate:cell.date];
|
||||
cell.subtitle = [self subtitleForDate:cell.date];
|
||||
cell.dateIsSelected = [_selectedDates containsObject:cell.date];
|
||||
cell.dateIsToday = [self isDateInToday:cell.date];
|
||||
|
|
@ -1893,6 +1895,18 @@ typedef NS_ENUM(NSUInteger, FSCalendarOrientation) {
|
|||
|
||||
#pragma mark - DataSource
|
||||
|
||||
- (NSString *)titleForDate:(NSDate *)date
|
||||
{
|
||||
#if !TARGET_INTERFACE_BUILDER
|
||||
if (_dataSource && [_dataSource respondsToSelector:@selector(calendar:titleForDate:)]) {
|
||||
return [_dataSource calendar:self titleForDate:date];
|
||||
}
|
||||
return nil;
|
||||
#else
|
||||
return _appearance.fakeSubtitles ? @"test" : nil;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (NSString *)subtitleForDate:(NSDate *)date
|
||||
{
|
||||
#if !TARGET_INTERFACE_BUILDER
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@
|
|||
@property (weak, nonatomic) FSCalendarEventIndicator *eventIndicator;
|
||||
|
||||
@property (strong, nonatomic) NSDate *date;
|
||||
@property (strong, nonatomic) NSString *title;
|
||||
@property (strong, nonatomic) NSString *subtitle;
|
||||
@property (strong, nonatomic) UIImage *image;
|
||||
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@
|
|||
if (self.contentView.hidden) {
|
||||
return;
|
||||
}
|
||||
_titleLabel.text = [NSString stringWithFormat:@"%@",@([_calendar dayOfDate:_date])];
|
||||
_titleLabel.text = self.title ?: [NSString stringWithFormat:@"%@",@([_calendar dayOfDate:_date])];
|
||||
if (_subtitle) {
|
||||
_subtitleLabel.text = _subtitle;
|
||||
if (_subtitleLabel.hidden) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue