コード例 #1
0
        public override CGSize GetReferenceSizeForFooter(UICollectionView collectionView, UICollectionViewLayout layout, nint section)
        {
            var width = UIScreen.MainScreen.Bounds.Width;

            return(FooterReuseID.IsNullOrEmpty() || ViewModel.BottomBanners == null || ViewModel.BottomBanners.Count == 0 ?
                   CGSize.Empty
                    :
                   new CGSize(width, width * 9 / 16));
        }
        public override UICollectionReusableView GetViewForSupplementaryElement(UICollectionView collectionView, NSString elementKind, NSIndexPath indexPath)
        {
            if (elementKind == UICollectionElementKindSectionKey.Header && !HeaderReuseID.IsNullOrEmtpy() && indexPath.Section == 1)
            {
                var headerView = collectionView.DequeueReusableSupplementaryView(elementKind, HeaderReuseID, indexPath);

                if (_headerDataContext != null)
                {
                    SetupReusableView(headerView, elementKind, indexPath, _headerDataContext);
                }

                return(headerView);
            }

            if (elementKind == UICollectionElementKindSectionKey.Header && !BannersHeaderReuseID.IsNullOrEmtpy() && indexPath.Section == 0)
            {
                var headerView = collectionView.DequeueReusableSupplementaryView(elementKind, BannersHeaderReuseID, indexPath);

                if (ViewModel != null)
                {
                    SetupReusableView(headerView, elementKind, indexPath, ViewModel);
                }

                return(headerView);
            }

            if (elementKind == UICollectionElementKindSectionKey.Footer && !FooterReuseID.IsNullOrEmtpy() && indexPath.Section == 1)
            {
                var footerView = collectionView.DequeueReusableSupplementaryView(elementKind, FooterReuseID, indexPath);

                if (ViewModel != null)
                {
                    SetupReusableView(footerView, elementKind, indexPath, ViewModel);
                }

                return(footerView);
            }

            return(null);
        }