Esempio n. 1
0
        public static CGSize TPKeyboardAvoiding_calculatedContentSizeFromSubviewFrames(this UIScrollView scrollView)
        {
            bool wasShowingVerticalScrollIndicator   = scrollView.ShowsVerticalScrollIndicator;
            bool wasShowingHorizontalScrollIndicator = scrollView.ShowsHorizontalScrollIndicator;

            scrollView.ShowsVerticalScrollIndicator   = false;
            scrollView.ShowsHorizontalScrollIndicator = false;

            CGRect rect = new CGRect(0, 0, 0, 0);

            foreach (var subview in scrollView.Subviews)
            {
                rect = CGRect.Union(rect, subview.Frame);
            }

            var size = rect.Size;

            size.Height += kCalculatedContentPadding;

            rect.Size = size;

            scrollView.ShowsVerticalScrollIndicator   = wasShowingVerticalScrollIndicator;
            scrollView.ShowsHorizontalScrollIndicator = wasShowingHorizontalScrollIndicator;

            return(rect.Size);
        }
Esempio n. 2
0
        private void UpdateSelectedPosition(bool animated)
        {
            // Labels

            this.UpdateLabelColors();

            // Strip

            var y      = this.selectedView.Frame.Y;
            var x      = TabWidth * SelectedIndex + (TabWidth / 2);
            var height = this.selectedView.Frame.Height;
            var width  = TabWidth;

            if (style.SelectedStripStyle == PagerStyle.StripStyle.Rounded)
            {
                width -= 2 * this.style.SelectedStripMargin;
            }
            else if (style.SelectedStripStyle == PagerStyle.StripStyle.Dot)
            {
                width = this.style.SelectedStripSize;
            }

            x -= width / 2;

            var destination = new CGRect(x, y, width, height);

            if (animated && this.style.SelectedStripAnimation != PagerStyle.StripAnimation.None)
            {
                if (this.style.SelectedStripAnimation == PagerStyle.StripAnimation.Stretched)
                {
                    var step         = CGRect.Union(selectedView.Frame, destination);
                    var stepDuration = this.style.SelectedStripAnimationDuration / 2;
                    UIView.Animate(stepDuration, 0, UIViewAnimationOptions.CurveEaseIn, () => this.selectedView.Frame = step, () =>
                    {
                        UIView.Animate(stepDuration, 0, UIViewAnimationOptions.CurveEaseOut, () => this.selectedView.Frame = destination, () => { });
                    });

                    UIView.Animate(this.style.SelectedStripAnimationDuration, 0, UIViewAnimationOptions.CurveEaseInOut, () =>
                    {
                        this.selectedView.BackgroundColor = GetStripColor(SelectedIndex);
                    }, () => { });
                }
                else if (this.style.SelectedStripAnimation == PagerStyle.StripAnimation.Constant)
                {
                    UIView.Animate(this.style.SelectedStripAnimationDuration, 0, UIViewAnimationOptions.CurveEaseInOut, () =>
                    {
                        this.selectedView.Frame           = destination;
                        this.selectedView.BackgroundColor = GetStripColor(SelectedIndex);
                    }, () => { });
                }
            }
            else
            {
                this.selectedView.Frame           = destination;
                this.selectedView.BackgroundColor = GetStripColor(SelectedIndex);
            }
        }
Esempio n. 3
0
        public override void LayoutSubviews()
        {
            this.layoutPopupIfNeeded();


            var boundingBox = (this.popup != null ? CGRect.Union(this.Bounds, this.popup.Frame) : this.Bounds);


            if (this.Bounds.Width == 0 || this.Bounds.Height == 0)
            {
                return;
            }
            if (oldBounds != null && boundingBox.Size.Equals(oldBounds?.Size))
            {
                return;
            }
            oldBounds = boundingBox;


            base.LayoutSubviews();


            CATransaction.Begin();

            CATransaction.DisableActions = (true);


            this.background.Frame = this.Bounds;

            this.label.Frame = new CGRect(this.labelInset, this.labelInset, this.Bounds.Width - this.labelInset * 2, this.Bounds.Height - this.labelInset * 2);

            this.displayView.Frame = boundingBox;
            this.shadowView.Frame  = boundingBox;
            this.borderView.Frame  = boundingBox;
            this.underView.Frame   = boundingBox;

            CATransaction.Commit();
            this.refreshViews();
        }
        public override void Draw(CGRect rect)
        {
            using (var context = UIGraphics.GetCurrentContext()) {
                var bounds = Bounds;

                //UIColor background = Enabled ? isPressed ? HighlightedColor : NormalColor : DisabledColor;

                UIColor buttonColor     = NormalColor;             //UIColor.FromRGBA (0.00f, 0.37f, 0.89f, 1.00f);
                var     buttonColorRGBA = new nfloat[4];
                buttonColor.GetRGBA(
                    out buttonColorRGBA [0],
                    out buttonColorRGBA [1],
                    out buttonColorRGBA [2],
                    out buttonColorRGBA [3]
                    );
                if (isPressed)
                {
                    // Get the Hue Saturation Brightness Alpha copy of the color
                    var buttonColorHSBA = new nfloat[4];
                    buttonColor.GetHSBA(
                        out buttonColorHSBA [0],
                        out buttonColorHSBA [1],
                        out buttonColorHSBA [2],
                        out buttonColorHSBA [3]
                        );
                    // Change the brightness to a fixed value (0.5f)
                    buttonColor = UIColor.FromHSBA(buttonColorHSBA [0], buttonColorHSBA [1], 0.5f, buttonColorHSBA [3]);
                    // Re-set the base buttonColorRGBA because everything else is relative to it
                    buttonColorRGBA = new nfloat[4];
                    buttonColor.GetRGBA(
                        out buttonColorRGBA [0],
                        out buttonColorRGBA [1],
                        out buttonColorRGBA [2],
                        out buttonColorRGBA [3]
                        );
                }

                using (var colorSpace = CGColorSpace.CreateDeviceRGB()) {
                    //// Abstracted Graphic Attributes
                    var textContent = this.Title(UIControlState.Normal);                      //"STOP";
                    var font        = UIFont.SystemFontOfSize(18);
                    // ------------- START PAINTCODE -------------

//// Color Declarations
                    UIColor frameColorTop    = UIColor.FromRGBA(0.20f, 0.20f, 0.20f, 1.00f);
                    UIColor frameShadowColor = UIColor.FromRGBA(1.00f, 1.00f, 1.00f, 0.40f);

                    UIColor glossyColorBottom = UIColor.FromRGBA(
                        (buttonColorRGBA [0] * 0.6f + 0.4f),
                        (buttonColorRGBA [1] * 0.6f + 0.4f),
                        (buttonColorRGBA [2] * 0.6f + 0.4f),
                        (buttonColorRGBA [3] * 0.6f + 0.4f)
                        );
                    UIColor glossyColorUp = UIColor.FromRGBA(
                        (buttonColorRGBA [0] * 0.2f + 0.8f),
                        (buttonColorRGBA [1] * 0.2f + 0.8f),
                        (buttonColorRGBA [2] * 0.2f + 0.8f),
                        (buttonColorRGBA [3] * 0.2f + 0.8f)
                        );

//// Gradient Declarations
                    var glossyGradientColors = new CGColor [] {
                        glossyColorUp.CGColor,
                        glossyColorBottom.CGColor
                    };
                    var glossyGradientLocations = new nfloat [] { 0, 1 };
                    var glossyGradient          = new CGGradient(colorSpace, glossyGradientColors, glossyGradientLocations);

//// Shadow Declarations
                    var frameInnerShadow            = frameShadowColor.CGColor;
                    var frameInnerShadowOffset      = new CGSize(0, -0);
                    var frameInnerShadowBlurRadius  = 3;
                    var buttonInnerShadow           = UIColor.Black.CGColor;
                    var buttonInnerShadowOffset     = new CGSize(0, -0);
                    var buttonInnerShadowBlurRadius = 12;
                    var textShadow           = UIColor.Black.CGColor;
                    var textShadowOffset     = new CGSize(0, -0);
                    var textShadowBlurRadius = 1;
                    var buttonShadow         = UIColor.Black.CGColor;

                    var buttonShadowOffset     = new CGSize(0, isPressed ? 0 : 2);                              // ADDED this code after PaintCode
                    var buttonShadowBlurRadius = isPressed ? 2 : 3;                                             // ADDED this code after PaintCode

//// outerFrame Drawing
                    var outerFramePath = UIBezierPath.FromRoundedRect(new CGRect(2.5f, 1.5f, 120, 32), 8);
                    context.SaveState();
                    context.SetShadow(buttonShadowOffset, buttonShadowBlurRadius, buttonShadow);
                    frameColorTop.SetFill();
                    outerFramePath.Fill();
                    context.RestoreState();

                    UIColor.Black.SetStroke();
                    outerFramePath.LineWidth = 1;
                    outerFramePath.Stroke();

//// innerFrame Drawing
                    var innerFramePath = UIBezierPath.FromRoundedRect(new CGRect(5.5f, 4.5f, 114, 26), 5);
                    context.SaveState();
                    context.SetShadow(frameInnerShadowOffset, frameInnerShadowBlurRadius, frameInnerShadow);
                    buttonColor.SetFill();
                    innerFramePath.Fill();

////// innerFrame Inner Shadow
                    var innerFrameBorderRect = innerFramePath.Bounds;
                    innerFrameBorderRect.Inflate(buttonInnerShadowBlurRadius, buttonInnerShadowBlurRadius);
                    innerFrameBorderRect.Offset(-buttonInnerShadowOffset.Width, -buttonInnerShadowOffset.Height);
                    innerFrameBorderRect = CGRect.Union(innerFrameBorderRect, innerFramePath.Bounds);
                    innerFrameBorderRect.Inflate(1, 1);

                    var innerFrameNegativePath = UIBezierPath.FromRect(innerFrameBorderRect);
                    innerFrameNegativePath.AppendPath(innerFramePath);
                    innerFrameNegativePath.UsesEvenOddFillRule = true;

                    context.SaveState();
                    {
                        var xOffset = buttonInnerShadowOffset.Width + (float)Math.Round(innerFrameBorderRect.Width);
                        var yOffset = buttonInnerShadowOffset.Height;
                        context.SetShadow(
                            new CGSize(xOffset + (xOffset >= 0 ? 0.1f : -0.1f), yOffset + (yOffset >= 0 ? 0.1f : -0.1f)),
                            buttonInnerShadowBlurRadius,
                            buttonInnerShadow);

                        innerFramePath.AddClip();
                        var transform = CGAffineTransform.MakeTranslation(-(float)Math.Round(innerFrameBorderRect.Width), 0);
                        innerFrameNegativePath.ApplyTransform(transform);
                        UIColor.Gray.SetFill();
                        innerFrameNegativePath.Fill();
                    }
                    context.RestoreState();

                    context.RestoreState();

                    UIColor.Black.SetStroke();
                    innerFramePath.LineWidth = 1;
                    innerFramePath.Stroke();

//// Rounded Rectangle Drawing
                    var roundedRectanglePath = UIBezierPath.FromRoundedRect(new CGRect(8, 6, 109, 9), 4);
                    context.SaveState();
                    roundedRectanglePath.AddClip();
                    context.DrawLinearGradient(glossyGradient, new CGPoint(62.5f, 6), new CGPoint(62.5f, 15), 0);
                    context.RestoreState();

//// Text Drawing
                    var textRect = new CGRect(18, 6, 90, 28);
                    context.SaveState();
                    context.SetShadow(textShadowOffset, textShadowBlurRadius, textShadow);
                    glossyColorUp.SetFill();

                    // Use default button-drawn text
                    //new NSString(textContent).DrawString(textRect, font, UILineBreakMode.WordWrap, UITextAlignment.Center);
                    context.RestoreState();

                    // ------------- END PAINTCODE -------------
                }
            }
        }
Esempio n. 5
0
        public override void Draw(CGRect rect)
        {
            using (var context = UIGraphics.GetCurrentContext()) {
                var bounds = Bounds;

                //UIColor background = Enabled ? isPressed ? HighlightedColor : NormalColor : DisabledColor;

                UIColor buttonColor     = NormalColor;             //UIColor.FromRGBA (0.00f, 0.37f, 0.89f, 1.00f);
                var     buttonColorRGBA = new nfloat[4];
                buttonColor.GetRGBA(
                    out buttonColorRGBA [0],
                    out buttonColorRGBA [1],
                    out buttonColorRGBA [2],
                    out buttonColorRGBA [3]
                    );
                if (isPressed)
                {
                    // Get the Hue Saturation Brightness Alpha copy of the color
                    var buttonColorHSBA = new nfloat[4];
                    buttonColor.GetHSBA(
                        out buttonColorHSBA [0],
                        out buttonColorHSBA [1],
                        out buttonColorHSBA [2],
                        out buttonColorHSBA [3]
                        );
                    // Change the brightness to a fixed value (0.5f)
                    buttonColor = UIColor.FromHSBA(buttonColorHSBA [0], buttonColorHSBA [1], 0.5f, buttonColorHSBA [3]);
                    // Re-set the base buttonColorRGBA because everything else is relative to it
                    buttonColorRGBA = new nfloat[4];
                    buttonColor.GetRGBA(
                        out buttonColorRGBA [0],
                        out buttonColorRGBA [1],
                        out buttonColorRGBA [2],
                        out buttonColorRGBA [3]
                        );
                }

                using (var colorSpace = CGColorSpace.CreateDeviceRGB()) {
                    // ------------- START PAINTCODE -------------

//// Color Declarations
                    UIColor upColorOut       = UIColor.FromRGBA(0.79f, 0.79f, 0.79f, 1.00f);
                    UIColor bottomColorDown  = UIColor.FromRGBA(0.21f, 0.21f, 0.21f, 1.00f);
                    UIColor upColorInner     = UIColor.FromRGBA(0.17f, 0.18f, 0.20f, 1.00f);
                    UIColor bottomColorInner = UIColor.FromRGBA(0.98f, 0.98f, 0.99f, 1.00f);

                    UIColor buttonFlareUpColor = UIColor.FromRGBA(
                        (buttonColorRGBA [0] * 0.3f + 0.7f),
                        (buttonColorRGBA [1] * 0.3f + 0.7f),
                        (buttonColorRGBA [2] * 0.3f + 0.7f),
                        (buttonColorRGBA [3] * 0.3f + 0.7f)
                        );
                    UIColor buttonTopColor = UIColor.FromRGBA(
                        (buttonColorRGBA [0] * 0.8f),
                        (buttonColorRGBA [1] * 0.8f),
                        (buttonColorRGBA [2] * 0.8f),
                        (buttonColorRGBA [3] * 0.8f + 0.2f)
                        );
                    UIColor buttonBottomColor = UIColor.FromRGBA(
                        (buttonColorRGBA [0] * 0 + 1),
                        (buttonColorRGBA [1] * 0 + 1),
                        (buttonColorRGBA [2] * 0 + 1),
                        (buttonColorRGBA [3] * 0 + 1)
                        );
                    UIColor buttonFlareBottomColor = UIColor.FromRGBA(
                        (buttonColorRGBA [0] * 0.8f + 0.2f),
                        (buttonColorRGBA [1] * 0.8f + 0.2f),
                        (buttonColorRGBA [2] * 0.8f + 0.2f),
                        (buttonColorRGBA [3] * 0.8f + 0.2f)
                        );
                    UIColor flareWhite = UIColor.FromRGBA(1.00f, 1.00f, 1.00f, 0.83f);

//// Gradient Declarations
                    var ringGradientColors = new CGColor [] {
                        upColorOut.CGColor,
                        bottomColorDown.CGColor
                    };
                    var ringGradientLocations   = new nfloat [] { 0, 1 };
                    var ringGradient            = new CGGradient(colorSpace, ringGradientColors, ringGradientLocations);
                    var ringInnerGradientColors = new CGColor [] {
                        upColorInner.CGColor,
                        bottomColorInner.CGColor
                    };
                    var ringInnerGradientLocations = new nfloat [] { 0, 1 };
                    var ringInnerGradient          = new CGGradient(colorSpace, ringInnerGradientColors, ringInnerGradientLocations);
                    var buttonGradientColors       = new CGColor [] {
                        buttonBottomColor.CGColor,
                        buttonTopColor.CGColor
                    };
                    var buttonGradientLocations = new nfloat [] { 0, 1 };
                    var buttonGradient          = new CGGradient(colorSpace, buttonGradientColors, buttonGradientLocations);
                    var overlayGradientColors   = new CGColor [] {
                        flareWhite.CGColor,
                        UIColor.Clear.CGColor
                    };
                    var overlayGradientLocations  = new nfloat [] { 0, 1 };
                    var overlayGradient           = new CGGradient(colorSpace, overlayGradientColors, overlayGradientLocations);
                    var buttonFlareGradientColors = new CGColor [] {
                        buttonFlareUpColor.CGColor,
                        buttonFlareBottomColor.CGColor
                    };
                    var buttonFlareGradientLocations = new nfloat [] { 0, 1 };
                    var buttonFlareGradient          = new CGGradient(colorSpace, buttonFlareGradientColors, buttonFlareGradientLocations);

//// Shadow Declarations
                    var buttonInnerShadow           = UIColor.Black.CGColor;
                    var buttonInnerShadowOffset     = new CGSize(0, -0);
                    var buttonInnerShadowBlurRadius = 5;
                    var buttonOuterShadow           = UIColor.Black.CGColor;
                    var buttonOuterShadowOffset     = new CGSize(0, 2);

                    var buttonOuterShadowBlurRadius = isPressed ? 2 : 5;                        // ADDED this code after PaintCode

//// outerOval Drawing
                    var outerOvalPath = UIBezierPath.FromOval(new CGRect(5, 5, 63, 63));
                    context.SaveState();
                    context.SetShadow(buttonOuterShadowOffset, buttonOuterShadowBlurRadius, buttonOuterShadow);
                    context.BeginTransparencyLayer(null);
                    outerOvalPath.AddClip();
                    context.DrawLinearGradient(ringGradient, new CGPoint(36.5f, 5), new CGPoint(36.5f, 68), 0);
                    context.EndTransparencyLayer();
                    context.RestoreState();

//// overlayOval Drawing
                    var overlayOvalPath = UIBezierPath.FromOval(new CGRect(5, 5, 63, 63));
                    context.SaveState();
                    overlayOvalPath.AddClip();
                    context.DrawRadialGradient(overlayGradient,
                                               new CGPoint(36.5f, 12.23f), 17.75f,
                                               new CGPoint(36.5f, 36.5f), 44.61f,
                                               CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation);
                    context.RestoreState();

//// innerOval Drawing
                    var innerOvalPath = UIBezierPath.FromOval(new CGRect(12, 12, 49, 49));
                    context.SaveState();
                    innerOvalPath.AddClip();
                    context.DrawLinearGradient(ringInnerGradient, new CGPoint(36.5f, 12), new CGPoint(36.5f, 61), 0);
                    context.RestoreState();

//// buttonOval Drawing
                    var buttonOvalPath = UIBezierPath.FromOval(new CGRect(14, 13, 46, 46));
                    context.SaveState();
                    buttonOvalPath.AddClip();
                    context.DrawRadialGradient(buttonGradient,
                                               new CGPoint(37, 63.23f), 2.44f,
                                               new CGPoint(37, 44.48f), 23.14f,
                                               CGGradientDrawingOptions.DrawsBeforeStartLocation | CGGradientDrawingOptions.DrawsAfterEndLocation);
                    context.RestoreState();

////// buttonOval Inner Shadow
                    var buttonOvalBorderRect = buttonOvalPath.Bounds;
                    buttonOvalBorderRect.Inflate(buttonInnerShadowBlurRadius, buttonInnerShadowBlurRadius);
                    buttonOvalBorderRect.Offset(-buttonInnerShadowOffset.Width, -buttonInnerShadowOffset.Height);
                    buttonOvalBorderRect = CGRect.Union(buttonOvalBorderRect, buttonOvalPath.Bounds);
                    buttonOvalBorderRect.Inflate(1, 1);

                    var buttonOvalNegativePath = UIBezierPath.FromRect(buttonOvalBorderRect);
                    buttonOvalNegativePath.AppendPath(buttonOvalPath);
                    buttonOvalNegativePath.UsesEvenOddFillRule = true;

                    context.SaveState();
                    {
                        var xOffset = buttonInnerShadowOffset.Width + (float)Math.Round(buttonOvalBorderRect.Width);
                        var yOffset = buttonInnerShadowOffset.Height;
                        context.SetShadow(
                            new CGSize(xOffset + (xOffset >= 0 ? 0.1f : -0.1f), yOffset + (yOffset >= 0 ? 0.1f : -0.1f)),
                            buttonInnerShadowBlurRadius,
                            buttonInnerShadow);

                        buttonOvalPath.AddClip();
                        var transform = CGAffineTransform.MakeTranslation(-(float)Math.Round(buttonOvalBorderRect.Width), 0);
                        buttonOvalNegativePath.ApplyTransform(transform);
                        UIColor.Gray.SetFill();
                        buttonOvalNegativePath.Fill();
                    }
                    context.RestoreState();

//// flareOval Drawing
                    var flareOvalPath = UIBezierPath.FromOval(new CGRect(22, 14, 29, 15));
                    context.SaveState();
                    flareOvalPath.AddClip();
                    context.DrawLinearGradient(buttonFlareGradient, new CGPoint(36.5f, 14), new CGPoint(36.5f, 29), 0);
                    context.RestoreState();

                    // ------------- END PAINTCODE -------------
                }
            }
        }
Esempio n. 6
0
        public override void PrepareLayout()
        {
            base.PrepareLayout();

            // Get the number of sections
            var numberofSections = CollectionView.NumberOfSections();

            if (numberofSections == 0)
            {
                return;
            }

            // Reset collections
            _headersAttributes.Clear();
            _footersAttributes.Clear();
            _unionRects.Clear();
            _columnHeights.Clear();
            _allItemAttributes.Clear();
            _sectionItemAttributes.Clear();

            // Initialize column heights
            for (int n = 0; n < ColumnCount; n++)
            {
                _columnHeights.Add((nfloat)0);
            }

            // Process all sections
            nfloat top         = 0.0f;
            var    attributes  = new UICollectionViewLayoutAttributes();
            var    columnIndex = 0;

            for (nint section = 0; section < numberofSections; ++section)
            {
                // Calculate section specific metrics
                var minimumInterItemSpacing = (MinimumInterItemSpacingForSection == null) ? MinimumColumnSpacing :
                                              MinimumInterItemSpacingForSection(CollectionView, this, section);

                // Calculate widths
                var width     = CollectionView.Bounds.Width - SectionInset.Left - SectionInset.Right;
                var itemWidth = (nfloat)Math.Floor((width - ((ColumnCount - 1) * MinimumColumnSpacing)) / ColumnCount);

                // Calculate section header
                var heightHeader = (HeightForHeader == null) ? HeaderHeight :
                                   HeightForHeader(CollectionView, this, section);

                if (heightHeader > 0)
                {
                    attributes       = UICollectionViewLayoutAttributes.CreateForSupplementaryView(UICollectionElementKindSection.Header, NSIndexPath.FromRowSection(0, section));
                    attributes.Frame = new CGRect(0, top, CollectionView.Bounds.Width, heightHeader);
                    _headersAttributes.Add(section, attributes);
                    _allItemAttributes.Add(attributes);

                    top = attributes.Frame.GetMaxY();
                }

                top += SectionInset.Top;
                for (int n = 0; n < ColumnCount; n++)
                {
                    _columnHeights [n] = top;
                }

                // Calculate Section Items
                var itemCount = CollectionView.NumberOfItemsInSection(section);
                List <UICollectionViewLayoutAttributes> itemAttributes = new List <UICollectionViewLayoutAttributes> ();

                for (nint n = 0; n < itemCount; n++)
                {
                    var indexPath = NSIndexPath.FromRowSection(n, section);
                    columnIndex = NextColumnIndexForItem(n);
                    var    xOffset    = SectionInset.Left + (itemWidth + MinimumColumnSpacing) * (nfloat)columnIndex;
                    var    yOffset    = _columnHeights [columnIndex];
                    var    itemSize   = (SizeForItem == null) ? new CGSize(0, 0) : SizeForItem(CollectionView, this, indexPath);
                    nfloat itemHeight = 0.0f;

                    if (itemSize.Height > 0.0f && itemSize.Width > 0.0f)
                    {
                        itemHeight = (nfloat)Math.Floor(itemSize.Height * itemWidth / itemSize.Width);
                    }

                    attributes       = UICollectionViewLayoutAttributes.CreateForCell(indexPath);
                    attributes.Frame = new CGRect(xOffset, yOffset, itemWidth, itemHeight);
                    itemAttributes.Add(attributes);
                    _allItemAttributes.Add(attributes);
                    _columnHeights [columnIndex] = attributes.Frame.GetMaxY() + MinimumInterItemSpacing;
                }
                _sectionItemAttributes.Add(itemAttributes);

                // Calculate Section Footer
                nfloat footerHeight = 0.0f;
                columnIndex  = LongestColumnIndex();
                top          = _columnHeights [columnIndex] - MinimumInterItemSpacing + SectionInset.Bottom;
                footerHeight = (HeightForFooter == null) ? FooterHeight : HeightForFooter(CollectionView, this, section);

                if (footerHeight > 0)
                {
                    attributes       = UICollectionViewLayoutAttributes.CreateForSupplementaryView(UICollectionElementKindSection.Footer, NSIndexPath.FromRowSection(0, section));
                    attributes.Frame = new CGRect(0, top, CollectionView.Bounds.Width, footerHeight);
                    _footersAttributes.Add(section, attributes);
                    _allItemAttributes.Add(attributes);
                    top = attributes.Frame.GetMaxY();
                }

                for (int n = 0; n < ColumnCount; n++)
                {
                    _columnHeights [n] = top;
                }
            }

            var i     = 0;
            var attrs = _allItemAttributes.Count;

            while (i < attrs)
            {
                var rect1 = _allItemAttributes [i].Frame;
                i = (int)Math.Min(i + _unionSize, attrs) - 1;
                var rect2 = _allItemAttributes [i].Frame;
                _unionRects.Add(CGRect.Union(rect1, rect2));
                i++;
            }
        }