我该怎么做?
我确定以前已经这样做过。我在github上检查了几个项目,例如calendar master,但它们都比我需要的更复杂。
2013 年 10 月
SM T W T F S
30 1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 311 2 3
有没有最好的方法来做到这一点?要以与该月的星期几相匹配的方式布局日期?
这将在表格 View 中进行,但我不是在寻找代码,只是在寻找其背后的逻辑。除非已经有一个非常好的解决方案。
谢谢!
最佳答案
逻辑可能是这样的(伪代码):
get the weekday of the first day of the month in question
determine the number of days of the previous month
fill the first line
with leading final days of previous month, if any
the remaining days for the first week of the month in question
fill all other lines
fill the rest of the last line
with the first days of the following month, if any space left
关于objective-c - 如何以编程方式在日历中以与月份和星期相匹配的方式布局日期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19347364/