Problems with FSCalendar CollectionView Height?

1.5k views Asked by At

CollectionView I tried to modify the height of the CollectionView using different methods like "calendar.collectionView.fs_height = 60" but nothing works. The CollectionView's height is calculated by a function. So I'm trying to disable this function or just be able to modify the height. Thanks!

this is the code

import UIKit import FSCalendar import SnapKit

class ViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()
    
    let calendar = FSCalendar(frame: CGRect(x: 0, y: 0, width: view.frame.width, height: 224))
    calendar.weekdayHeight = 30
    calendar.dataSource = self
    calendar.delegate = self
    calendar.scope = .week
    calendar.register(FSCalendarCell.self, forCellReuseIdentifier: "Cell")
    
    view.addSubview(calendar)

}



func calendar(_ calendar: FSCalendar, boundingRectWillChange bounds: CGRect, animated: Bool) {
    calendar.snp.updateConstraints { (make) in
        make.height.equalTo(bounds.height)
        make.top.equalTo(40)

    }
    self.view.layoutIfNeeded()
}

}

extension ViewController: FSCalendarDelegate, FSCalendarDataSource {

func calendar(_ calendar: FSCalendar, cellFor date: Date, at position: FSCalendarMonthPosition) -> FSCalendarCell {
    let cell = calendar.dequeueReusableCell(withIdentifier: "Cell", for: date, at: position)
    cell.fs_height = 35
    return cell
}

}

1

There are 1 answers

0
Hugo Perez On

please paste the code where you are attempting this.

The size of the collectionView is defined either by the size of the frame you are setting for it(not recommender) or determined by the constraints on your layout.

Your issue seems documented in FSCalendar repository page, they state

FSCalendar doesn't update frame by itself, Please implement

Here the link to that section

Check what system are you using for layout, and implement

boundingRectWillChange