如何在UICollectionView的页脚中添加UIActivityIndi​​catorView?

iam*_*old 5 footer uiactivityindicatorview uicollectionview swift

如何在swift中添加UIActivityIndicatorView页脚UICollectionView?因为UITableView,它只是self.tableView.tableFootView = self.myActivityIndicatorView.这可能吗?如果是这样,怎么样?

小智 1

创建视图类并在该视图中添加活动指示

使用以下方法将此类注册为页脚视图类:

registerClass(myFooterViewClass, forSupplementaryViewOfKind: UICollectionElementKindSectionFooter, withReuseIdentifier: "myFooterView")
Run Code Online (Sandbox Code Playgroud)

在集合视图布局上设置 headerReferenceSize 或实施

collectionView:layout:referenceSizeForHeaderInSection: in your delegate.
Run Code Online (Sandbox Code Playgroud)

通过数据源中的以下方法返回页脚视图:

func collectionView(collectionView: UICollectionView, viewForSupplementaryElementOfKind kind: String, atIndexPath indexPath: NSIndexPath) -> UICollectionReusableView {
let view = collectionView.dequeueReusableSupplementaryViewOfKind(UICollectionElementKindSectionFooter, withReuseIdentifier: "myFooterView", forIndexPath: indexPath)
// configure footer view
return view
}
Run Code Online (Sandbox Code Playgroud)