我創建了單個視圖項目並添加了一個collectionView。我註冊UICollectionReusableViewiOS11 UICollectionSectionHeader剪裁滾動指標
final class TestReusableView: UICollectionReusableView {
override init(frame: CGRect) {
super.init(frame: frame)
backgroundColor = UIColor.red
}
...
}
集的數據源和委託的一個簡單的子類來自
extension ViewController: UICollectionViewDataSource {
func numberOfSections(in collectionView: UICollectionView) -> Int {
return 1
}
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return 100
}
func collectionView(_ collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, at indexPath: IndexPath) -> UICollectionReusableView {
let headerView = collectionView.dequeueReusableSupplementaryView(ofKind: kind, withReuseIdentifier: kHeader, for: indexPath)
return headerView
}
func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "cell", for: indexPath)
cell.backgroundColor = UIColor.blue
return cell
}
}
extension ViewController: UICollectionViewDelegateFlowLayout {
func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, referenceSizeForHeaderInSection section: Int) -> CGSize {
return CGSize(width: collectionView.bounds.width, height: 88)
}
}
結果是節頭似乎被定位在垂直滾動指示器的上方。但是,如果我針對10.3.1模擬器運行該應用程序,則行爲將按我的預期運行。
我曾經也遇到過類似的問題與iOS 11.0,其中部分頭被定位高於一切的看法。一切正常,在10.3。 – Aks
絕對看起來像iOS 11.0+問題。我也遇到了它。最近的雷達我可以找到這個:http://www.openradar.me/34308893 – isoiphone