2

これどうやってするの?

私はこれが以前に行われたと確信しています。カレンダー マスターなど、github でいくつかのプロジェクトを確認しましたが、それらはすべて必要以上に複雑です。

2013年10月

SMTWTFS

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 31 1 2 3

これを行うための最良の方法はありますか? その月の曜日に合わせて日をレイアウトするには?

これはテーブルビューで作成されますが、コードを探しているのではなく、その背後にあるロジックだけを探しています。本当に良い解決策がすでにそこにない限り。

ありがとうございました!

4

1 に答える 1

2

ロジックは次のようになります (疑似コード)。

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
于 2013-10-13T16:38:17.460 に答える