【发布时间】:2020-10-12 21:13:27
【问题描述】:
CollectionView 我尝试使用不同的方法修改 CollectionView 的高度,例如“calendar.collectionView.fs_height = 60”,但没有任何效果。 CollectionView 的高度由函数计算。所以我试图禁用这个功能或者只是能够修改高度。谢谢!
这是代码
导入 UIKit 导入FSCalendar 导入 SnapKit
类视图控制器: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
}
}
【问题讨论】:
标签: swift calendar fscalendar