gpt4 book ai didi

ios - 如何实现两周模式的日历 View (使用JTCalendar示例)

转载 作者:行者123 更新时间:2023-12-03 19:49:56 25 4
gpt4 key购买 nike

enter image description here我已经实现了 JTCalendar View 来获取月 View 和周 View ,但在周 View 中,我需要获取两周 View 。建议我编码。

JTCalendar 代码:

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.;
}
}
}

最佳答案

在月 View 中更改周数显示为 3还要在委托(delegate)方法 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;
// }
}

在 JTCalendar updatePage 方法中将 7 更改为 14,如下

 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));
}

关于ios - 如何实现两周模式的日历 View (使用JTCalendar示例),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29160361/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com