Esempio n. 1
0
        public override UICollectionViewCell GetCell(UICollectionView collectionView, NSIndexPath indexPath)
        {
            var cell = collectionView.DequeueReusableCell(TabCollectionCell.cellIdentifier(), indexPath) as TabCollectionCell;

            configureCell(cell, indexPath: indexPath, tabView);
            return(cell);
        }
Esempio n. 2
0
        public TabView(bool _isInfinity, TabPageOption _option) : base(CGRect.Empty)
        {
            option     = _option;
            isInfinity = _isInfinity;
            NSBundle.FromClass(new ObjCRuntime.Class(typeof(TabView))).LoadNib(nameof(TabView), this, null);
            AddSubview(contentView);
            contentView.BackgroundColor = option.tabBackgroundColor.ColorWithAlpha(option.tabBarAlpha);

            var top    = NSLayoutConstraint.Create(contentView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, this, NSLayoutAttribute.Top, 1.0f, 0.0f);
            var left   = NSLayoutConstraint.Create(contentView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, this, NSLayoutAttribute.Leading, 1.0f, 0.0f);
            var bottom = NSLayoutConstraint.Create(this, NSLayoutAttribute.Bottom, NSLayoutRelation.Equal, contentView, NSLayoutAttribute.Bottom, 1.0f, 0.0f);
            var right  = NSLayoutConstraint.Create(this, NSLayoutAttribute.Trailing, NSLayoutRelation.Equal, contentView, NSLayoutAttribute.Trailing, 1.0f, 0.0f);

            contentView.TranslatesAutoresizingMaskIntoConstraints = false;
            this.AddConstraints(new NSLayoutConstraint[] { top, left, bottom, right });

            var bundle = NSBundle.FromClass(new ObjCRuntime.Class(typeof(TabView)));
            var nib    = UINib.FromName(TabCollectionCell.cellIdentifier(), bundle);

            collectionView.RegisterNibForCell(nib, TabCollectionCell.cellIdentifier());
            cellForSize = nib.Instantiate(null, null).First() as TabCollectionCell;

            collectionView.ScrollsToTop = false;
            collectionView.DataSource   = this;
            collectionView.Delegate     = this;
            //collectionView.SetCollectionViewLayout(this, true);
            collectionView.Delegate = this;

            currentBarView.BackgroundColor          = option.currentColor;
            currentBarViewHeightConstraint.Constant = option.currentBarHeight;

            if (!isInfinity)
            {
                currentBarView.RemoveFromSuperview();
                collectionView.AddSubview(currentBarView);
                collectionView.TranslatesAutoresizingMaskIntoConstraints = false;

                var topOne = NSLayoutConstraint.Create(currentBarView, NSLayoutAttribute.Top, NSLayoutRelation.Equal, collectionView, NSLayoutAttribute.Top, 1.0f,
                                                       option.tabHeight - currentBarViewHeightConstraint.Constant);
                var leftOne = NSLayoutConstraint.Create(currentBarView, NSLayoutAttribute.Leading, NSLayoutRelation.Equal, collectionView, NSLayoutAttribute.Leading, 1.0f, 0.0f);

                currentBarViewLeftConstraint = leftOne;
                collectionView.AddConstraints(new[] { topOne, leftOne });
            }

            bottomBarViewHeightConstraint.Constant = 1.0f / UIScreen.MainScreen.Scale;
        }