Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,11 @@ -(void)applyCustomDefaults

NSLog(@"%@ %f", attributes[CLCalendarBackgroundImageColor], self.selectedDatePrintFontSize);
self.backgroundImageColor = attributes[CLCalendarBackgroundImageColor];
[self refreshBackgroundImageColor];

[self setNeedsDisplay];
}

-(UIView *)dailyInfoSubViewContainer
{
if(!_dailyInfoSubViewContainer){
Expand All @@ -126,13 +128,15 @@ -(UIView *)dailyInfoSubViewContainer
}
return _dailyInfoSubViewContainer;
}

-(UIImageView *)weatherIcon
{
if(!_weatherIcon){
_weatherIcon = [[UIImageView alloc] initWithFrame:CGRectMake(WEATHER_ICON_LEFT, WEATHER_ICON_MARGIN_TOP, WEATHER_ICON_WIDTH, WEATHER_ICON_HEIGHT)];
}
return _weatherIcon;
}

-(UILabel *)dateInfoLabel
{
if(!_dateInfoLabel){
Expand All @@ -144,6 +148,7 @@ -(UILabel *)dateInfoLabel
_dateInfoLabel.textColor = self.selectedDatePrintColor;
return _dateInfoLabel;
}

-(UIView *)dayTitleSubViewContainer
{
if(!_dayTitleSubViewContainer){
Expand All @@ -155,6 +160,7 @@ -(UIView *)dayTitleSubViewContainer
return _dayTitleSubViewContainer;

}

-(UIView *)dailySubViewContainer
{
if(!_dailySubViewContainer){
Expand All @@ -165,6 +171,7 @@ -(UIView *)dailySubViewContainer
}
return _dailySubViewContainer;
}

-(UIImageView *)backgroundImageView
{
if(!_backgroundImageView){
Expand Down Expand Up @@ -192,9 +199,19 @@ -(UIImageView *)backgroundImageView
[recognizerLeft setDirection:UISwipeGestureRecognizerDirectionLeft];
[_backgroundImageView addGestureRecognizer:recognizerLeft];
}
_backgroundImageView.backgroundColor = self.backgroundImageColor? self.backgroundImageColor : [UIColor colorWithPatternImage:[UIImage calendarBackgroundImage:self.bounds.size.height]];;

[self refreshBackgroundImageColor];

return _backgroundImageView;
}

- (void)refreshBackgroundImageColor
{
_backgroundImageView.backgroundColor = self.backgroundImageColor
? self.backgroundImageColor
: [UIColor colorWithPatternImage:[UIImage calendarBackgroundImage:self.bounds.size.height]];
}

-(void)initDailyViews
{
CGFloat dailyWidth = self.bounds.size.width/WEEKLY_VIEW_COUNT;
Expand Down Expand Up @@ -280,15 +297,18 @@ -(void)markDateSelected:(NSDate *)date

self.dateInfoLabel.text = strDate;
}

-(void)dailyInfoViewDidClick: (UIGestureRecognizer *)tap
{
//Click to jump back to today
[self redrawToDate:[NSDate new] ];
}

-(void)dayTitleViewDidClick: (UIGestureRecognizer *)tap
{
[self redrawToDate:((DayTitleLabel *)tap.view).date];
}

-(void)redrawToDate:(NSDate *)dt
{
if(![dt isWithinDate:self.startDate toDate:self.endDate]){
Expand All @@ -298,11 +318,13 @@ -(void)redrawToDate:(NSDate *)dt

[self dailyCalendarViewDidSelect:dt];
}

-(void)redrawCalenderData
{
[self redrawToDate:self.selectedDate];

}

-(void)adjustDailyInfoLabelAndWeatherIcon: (BOOL)blnShowWeatherIcon
{
self.dateInfoLabel.textAlignment = (blnShowWeatherIcon)?NSTextAlignmentLeft:NSTextAlignmentCenter;
Expand All @@ -326,10 +348,12 @@ -(void)swipeLeft: (UISwipeGestureRecognizer *)swipe
{
[self delegateSwipeAnimation: NO blnToday:NO selectedDate:nil];
}

-(void)swipeRight: (UISwipeGestureRecognizer *)swipe
{
[self delegateSwipeAnimation: YES blnToday:NO selectedDate:nil];
}

-(void)delegateSwipeAnimation: (BOOL)blnSwipeRight blnToday: (BOOL)blnToday selectedDate:(NSDate *)selectedDate
{
CATransition *animation = [CATransition animation];
Expand Down
1 change: 1 addition & 0 deletions CLWeeklyCalendarView/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ -(NSDictionary *)CLCalendarBehaviorAttributes
{
return @{
CLCalendarWeekStartDay : @2, //Start Day of the week, from 1-7 Mon-Sun -- default 1
// CLCalendarBackgroundImageColor: [UIColor redColor],
// CLCalendarDayTitleTextColor : [UIColor yellowColor],
// CLCalendarSelectedDatePrintColor : [UIColor greenColor],
};
Expand Down