protected void LayoutBar() { if (SelectedIndex < 0) { return; } if (ShellSectionController.GetItems().IndexOf(ShellSection.CurrentItem) != SelectedIndex) { return; } var layout = CollectionView.GetLayoutAttributesForItem(NSIndexPath.FromItemSection((int)SelectedIndex, 0)); if (layout == null) { return; } var frame = layout.Frame; if (_bar.Frame.Height != 2) { _bar.Frame = new CGRect(frame.X, frame.Bottom - 2, frame.Width, 2); } else { UIView.Animate(.25, () => _bar.Frame = new CGRect(frame.X, frame.Bottom - 2, frame.Width, 2)); } }
protected void LayoutBar() { var layout = CollectionView.GetLayoutAttributesForItem(NSIndexPath.FromItemSection((int)SelectedIndex, 0)); var frame = layout.Frame; if (_bar.Frame.Height != 2) { _bar.Frame = new CGRect(frame.X, frame.Bottom - 2, frame.Width, 2); } else { UIView.Animate(.25, () => _bar.Frame = new CGRect(frame.X, frame.Bottom - 2, frame.Width, 2)); } }
private void ScrollToIndex(int index, bool animated) { var indexPath = NSIndexPath.FromItemSection(index, 0); var attributes = CollectionView.GetLayoutAttributesForItem(indexPath); if (CollectionView != null && attributes != null) { var halfWidth = CollectionView.Frame.Width / 2; var offset = new CGPoint(attributes.Frame.GetMidX() - halfWidth, 0); CollectionView.SetContentOffset(offset, animated); } else { return; } }