-->

Using a UICollectionView to build a Monthly/Weekly

2020-08-04 10:04发布

问题:

I want to build a calendar using a UICollectionView. The calendar should have two layouts: Weekly - 7 days with paging. Should be horizontally scrollable. Monthly - full month with paging. Should be horizontally scrollable.

I want a "numbers only" calendar - something that works like the iOS native calendar (without the full daily schedule - just the numbers)

The user should be able to move from layout to layout by dragging the bottom of the collection view (making the week bigger to see a full month view, making the month smaller to see a week view)

I tried solving this but encountered a few issues:

  1. When the watching the monthly view (horizontal scrolling) the days are shown in columns (2nd day is under the 1st day instead of to the right)
  2. Transitioning between the two layouts never looks good enough (I don't want days to appear and fly into screen - I want it to just appear from the top and bottom while the collection view is getting bigger)

回答1:

UICollectionView is a good idea. But , it might take you a while. That is a good example from cocoa controls link



回答2:

I don't know if you have found a solution to this answer yet but, if you still need an example (and you use CocoaPods), you can head to the cocoapod site and do a search for calendars. You can find a list to choose from at ->> Cocoapds.org. There are some in this list that do exactly what you want to do. You can use them in your project, or you can roll your own by using them as an example. Rolling your own may take some time though.