FSCalendar CollectionView高度有问题吗?

问题描述

CollectionView我尝试使用“ calendar.collectionView.fs_height = 60”之类的不同方法来修改CollectionView的高度,但是没有任何效果。 CollectionView的高度由一个函数计算。因此,我试图禁用此功能或仅能够修改高度。谢谢!

这是代码

导入UIKit 进口FSCalendar 导入SnapKit

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()
}

}

扩展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
}

}

解决方法

请将代码粘贴到尝试执行此操作的地方。

collectionView的大小由您为其设置的框架的大小(不是推荐者)定义,或者由布局上的约束条件决定。

您的问题似乎记录在FSCalendar存储库页面中,

FSCalendar不会自行更新框架,请实施

Here the link to that section

检查您要使用哪种系统进行布局,并实施

boundingRectWillChange

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...