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
}}
发布于 2020-10-13 13:21:07
请将代码粘贴到您尝试执行此操作的位置。
collectionView的大小由您为其设置的框架(不是推荐器)的大小定义,或者由布局上的约束确定。
他们表示,您的问题似乎记录在FSCalendar存储库页面中
FSCalendar不会自行更新框架,请实现
检查您使用什么系统进行布局,并实现
boundingRectWillChangehttps://stackoverflow.com/questions/64325429
复制相似问题