UICollectionView in landscape on iPhone X

前端 未结 6 716
余生分开走
余生分开走 2021-01-31 02:41

When iPhone X is used landscape, you\'re supposed to check safeAreaInsets to make suitably large gutters on the left and right. UITableView has the new insetsContentViewsT

6条回答
  •  轮回少年
    2021-01-31 03:12

    Thanks to above for help. For my UICollectionViewController subClass, I added the following to viewDidLoad() (Swift 3):

    if let flowLayout = collectionView?.collectionViewLayout as? UICollectionViewFlowLayout {
        if #available(iOS 11.0, *) {
            flowLayout.sectionInsetReference = .fromSafeArea
        }
    }
    

提交回复
热议问题