Summary of problem
I'm building a calendar app in Swift, and I'd like to start with the UI in this repo: https://github.com/erichoracek/MSCollectionViewCalendarLayout
This repo is written in Objective-C.
However, I'm not sure how to build on top of this Github repo using Swift.
Example of the UI I'd like to use in my calendar:
What I've tried
- I successfully installed this library with CocoaPods.
- I ran
$pod install
. - I successfully ran
import MSCollectionViewCalendarLayout
. - I added a new
CollectionViewController
on my Storyboard, and assigned it to my customCalendarViewController
class - I tried (dumbly) with the code below in
class CalendarViewController
,but I get this error message:
"Cannot assign value of type 'MSCollectionViewCalendarLayout.Type' to type 'UICollectionViewLayout'"
override func viewDidLoad() {
super.viewDidLoad()
self.collectionView.collectionViewLayout = MSCollectionViewCalendarLayout
}
I understand I probably have to use
self.collectionView.register(cellClass:forCellWithReuseIdentifier:)
...but how?There's some documentation titled "Usage" in the Github, but unfortunately I'm still lost as to how to use it:
There's also an Example.xcworkspace included, written in Objective-C. I've gone through most of it. They include header (.h) and implementation (.m) files for each of the elements that they use.
There's a good answer to a tangential problem here: https://stackoverflow.com/a/45540130/3979651, but this doesn't directly solve my problem. I'd like to
import
this Cocoapods library, instead of writing on top of Objective-C files. But I'm also not entirely sure if this is the right / best way to do it.
Summary of questions
- How do I link my
CollectionViewController
toMSCollectionViewCalendarLayout
so that it has the same UI? - How do I use
self.collectionView.register(cellClass:forCellWithReuseIdentifier:)
in this case? - Do I have to write a new file for each element, like in the Example? (Event cell, Day Column Header, etc.)
- Or, would it be easier to just copy and paste the Example element files (.h and .m) into my app? If so, how do I build on top of those files?
What I'd like to accomplish
I would like to import MSCollectionViewLayout
like a library, attach it to my own CollectionViewControllers
, and build my own functionality on top of this, all using Swift.
Thank you all in advance! Hopefully I can commit the correct answers here to the repo's README.md file.