WenchaoD / FSCalendar

A fully customizable iOS calendar library, compatible with Objective-C and Swift
MIT License
10.61k stars 1.94k forks source link

How to add contentInset to scrollview / collectionview / calendar? #1418

Open sebasdeweert opened 1 year ago

sebasdeweert commented 1 year ago

How can I add a contentInset to the calendar view?

I want to have an inset on the left and right sides.

Now, when I do this with constraints and I scroll the page, the calendar is cut off at the edge. I want to use contentInset to eliminate this edge and make the swipe smoother, utilizing the full-screen edges.

I tried this code, but it's not working: self.calendar.collectionView.contentInset = UIEdgeInsets(top: 0.0, left: 40.0, bottom: 0.0, right: 40.0)

My calendar right now with constraint:

Screenshot 2023-10-31 at 17 41 57

What I would like to achieve:

Screenshot 2023-10-31 at 17 41 40

Thanks!!

Dongju3079 commented 2 months ago

calendar.calendarWeekdayView.snp.makeConstraints { make in make.horizontalEdges.equalToSuperview().inset(24) make.height.equalTo(36) }

calendar.collectionViewLayout.sectionInsets = .init(top: 5, left: 24, bottom: 5, right: 24)