0

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:

calendar ui

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 custom CalendarViewController class
  • I tried (dumbly) with the code below in class CalendarViewController,but I get this error message:

Screenshot of 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:

Screenshot of "Usage" section in Github repo

  • 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.

    Screenshot of Example.xcworkspace

  • 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

  1. How do I link my CollectionViewController to MSCollectionViewCalendarLayout so that it has the same UI?
  2. How do I use self.collectionView.register(cellClass:forCellWithReuseIdentifier:) in this case?
  3. Do I have to write a new file for each element, like in the Example? (Event cell, Day Column Header, etc.)
  4. 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.

l'L'l
  • 44,951
  • 10
  • 95
  • 146

1 Answers1

2

You can better use one of the below repos which are purely written in Swift and has the same UI as of MSCollectionViewLayout

1) CalendarKit

2) Calendar

Note: I personally used these libraries and these are easy to integrate with your existing application.

Muhammad Waqas Bhati
  • 2,775
  • 20
  • 25