首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >FSCalendar CollectionView Height有问题吗?

FSCalendar CollectionView Height有问题吗?
EN

Stack Overflow用户
提问于 2020-10-13 05:13:27
回答 1查看 313关注 0票数 0

CollectionView我尝试使用不同的方法修改CollectionView的高度,比如"calendar.collectionView.fs_height = 60“,但都不起作用。CollectionView的高度由一个函数计算。因此,我正在尝试禁用此功能,或者只是能够修改高度。谢谢!

这是代码

导入UIKit导入FSCalendar导入SnapKit

类ViewController: UIViewController {

代码语言:javascript
复制
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 {

代码语言:javascript
复制
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
}

}

EN

回答 1

Stack Overflow用户

发布于 2020-10-13 13:21:07

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

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

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

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

Here the link to that section

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

代码语言:javascript
复制
boundingRectWillChange
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/64325429

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档