Closed simonmaddox closed 11 years ago
Yay.
I think this patch might not work too well because DayFlow uses this logic:
1
).Drawing the activity into the image will change how the day shows up in each month, and generally will not be what you want. DayFlow should have the drawing parts refactored into a class method to avoid confusion. Instead, one way around this is to implement the day activity dot as a separate subview — think about something like this:
@property (nonatomic, readonly, strong) UIImageView *activityDot;
then, in your cell subclass, look at -layoutSubviews
and say:
self.activityDot.hidden = !self.hasActivity;
and then implement the - (void) setHasActivity:(BOOL)flag
setter:
- (void) setHasActivity:(BOOL)flag {
_hasActivity = flag;
[self setNeedsLayout];
}
then, make sure you are using a custom subclass of DFDatePickerView
, and do this:
- (DFDatePickerDayCell *) collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
DFDatePickerDayCell *cell = [super collectionView:collectionView cellForItemAtIndexPath:indexPath];
cell.hasActivity = [self hasActivityForPickerDate:cell.date];
return cell;
}
Note that internally, DayFlow uses a DFDatePickerDate
struct to save time. If your custom code determining whether a certain date has activities uses NSDate
internally, you can use [DFDatePickerView dateFromPickerDate:]
— currently a private method — to get a fresh NSDate
object from that picker date.
Thanks for using DayFlow and please let me know your thoughts.
Like the iOS calendar app:
Don't mind if you decide not to accept the Pull Request. DayFlow is perfect for something I'm working on, but needed this tiny tweak. I figured I'd send it back in case you want it.
Thanks!