Reputation: 726
I have implemented JTCalendar view to get both month and week view but in week view,i need to get two week view .Suggest me coding.
JTCalendar code:
CGFloat x = 0;
CGFloat width = self.frame.size.width / 7.;
CGFloat height = self.frame.size.height;
if(self.calendarManager.calendarAppearance.readFromRightToLeft)
{
for(UIView *view in [[self.subviews reverseObjectEnumerator] allObjects])
{
view.frame = CGRectMake(x, 0, width, height);
x = CGRectGetMaxX(view.frame);
}
}
else{
for(UIView *view in self.subviews)
{
view.frame = CGRectMake(x, 0, width, height);
x = CGRectGetMaxX(view.frame);
}
}
[super layoutSubviews];
#//weeksToDisplay
- (void)configureConstraintsForSubviews
{
CGFloat weeksToDisplay;
if(cacheLastWeekMode)
{
weeksToDisplay = 1 ;
}
else{
weeksToDisplay = (CGFloat)(WEEKS_TO_DISPLAY + 1); // + 1 for weekDays
}
CGFloat y = 0;
CGFloat width = self.frame.size.width;
CGFloat height = self.frame.size.height / weeksToDisplay;
for(int i = 0; i < self.subviews.count; ++i){
UIView *view = self.subviews[i];
view.frame = CGRectMake(0, y, width, height);
y = CGRectGetMaxY(view.frame);
if(cacheLastWeekMode && i == weeksToDisplay + 1){
height = 0.;
}
}
}
Upvotes: 3
Views: 1769
Reputation: 726
- (void)setBeginningOfMonth:(NSDate *)date
{
NSDate *currentDate = date;
NSCalendar *calendar = self.calendarManager.calendarAppearance.calendar;
{
NSDateComponents *comps = [calendar components:NSCalendarUnitMonth|NSCalendarUnitDay fromDate:currentDate];
currentMonthIndex = comps.month;
// Hack
if(comps.day >7)
{
currentMonthIndex = (currentMonthIndex % 12) + 1;
}
}
for(JTCalendarWeekView *view in weeksViews)
{
view.currentMonthIndex = currentMonthIndex;
[view setBeginningOfWeek:currentDate];
NSDateComponents *dayComponent = [NSDateComponents new];
dayComponent.day = 7;
currentDate = [calendar dateByAddingComponents:dayComponent toDate:currentDate options:0];
// Doesn't need to do other weeks
// if(self.calendarManager.calendarAppearance.isWeekMode)
// {
// break;
// }
}
}
Upvotes: 0
Reputation: 207
In MonthView Change Weeks to display as 3 also do this comment the following code in delegate method setBeginingofmonth
for(JTCalendarWeekView *view in weeksViews)
{
view.currentMonthIndex = currentMonthIndex;
[view setBeginningOfWeek:currentDate];
NSDateComponents *dayComponent = [NSDateComponents new];
dayComponent.day = 7;
currentDate = [calendar dateByAddingComponents:dayComponent toDate:currentDate options:0];
// Doesn't need to do other weeks
// if(self.calendarManager.calendarAppearance.isWeekMode)
// {
// break;
// }
}
in JTCalendar updatePage method change 7 to 14 as below
if(!self.calendarAppearance.isWeekMode)
{
dayComponent.month = currentPage - (NUMBER_PAGES_LOADED / 2);
}
else
{
//to show next starting week for two weeks mode put 14
dayComponent.day = 14 * (currentPage - (NUMBER_PAGES_LOADED / 2));
}
Upvotes: 1
Reputation: 726
change the weeksToDisplay.
if(cacheLastWeekMode)
{
weeksToDisplay = 3 ;
}
Upvotes: 1