【问题标题】:Problems with FSCalendar CollectionView Height?FSCalendar CollectionView 高度问题?
【发布时间】: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


    【解决方案1】:

    请将代码粘贴到您尝试执行此操作的位置。

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

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

    FSCalendar 自身不更新帧,请实现

    Here the link to that section

    检查您使用什么系统进行布局,并实施

    boundingRectWillChange
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-02-14
      • 1970-01-01
      • 1970-01-01
      • 2021-06-21
      • 2019-01-14
      • 2011-01-25
      • 2011-11-29
      相关资源
      最近更新 更多