FSCalendar集合视图高度有问题



CollectionView我试图使用不同的方法修改CollectionView的高度,比如"calendar.collectionView.fs_height=60";但什么都不管用。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本身不更新帧,请实现

这里是部分的链接

检查您使用的布局系统,并实施

boundingRectWillChange

最新更新