【发布时间】:2014-10-20 07:59:43
【问题描述】:
我已经使用集合视图构建了一个自定义日历。我的问题是,当我添加UICollectionViewFlowLayout 时,它会覆盖整个屏幕并且不会留在UICollectionView 内。如何让UICollectionViewFlowLayout 留在UICollectionView 内?这是我的代码:
let layout: UICollectionViewFlowLayout = UICollectionViewFlowLayout()
layout.sectionInset = UIEdgeInsets(top: 100, left: 10, bottom: 1, right: 10)
let width = UIScreen.mainScreen().bounds.width
layout.itemSize = CGSize(width: width/10, height: 35)
collectionView = UICollectionView(frame: self.view.frame, collectionViewLayout: layout)
collectionView!.dataSource = self
collectionView!.delegate = self
collectionView!.registerClass(CollectionViewCell.self, forCellWithReuseIdentifier: "CollectionViewCell")
collectionView!.backgroundColor = UIColor.whiteColor()
self.view.addSubview(collectionView!)
我希望日历在哪里:
这是它覆盖整个屏幕的方式:
【问题讨论】:
标签: ios objective-c xcode swift uicollectionview