コード例 #1
0
        private void InitializeCollectionView()
        {
            // transButton
            transButton = new UIButton();
            transButton.AutoresizingMask = UIViewAutoresizing.All;
            transButton.Frame            = new CGRect(0, 0, this.View.Frame.Width, this.View.Frame.Height);
            transButton.BackgroundColor  = UIColor.Black;
            transButton.Alpha            = 0f;
            transButton.TouchUpInside   += HandleTransButtonTouchUpInside;
            this.View.AddSubview(transButton);

            // Set initial location to bottom of the screen
            UICollectionViewFlowLayout flowLayout = new UICollectionViewFlowLayout()
            {
                ScrollDirection     = UIKit.UICollectionViewScrollDirection.Horizontal,
                ItemSize            = new CGSize(150, 100),
                MinimumLineSpacing  = 10.0f,
                SectionInset        = new UIEdgeInsets(0, 20, 0, 20),
                HeaderReferenceSize = new CGSize(150, 200)
            };

            collectionView = new UICollectionView(new CGRect(0, this.View.Frame.Bottom, this.View.Frame.Width, COLLECTIONVIEW_HEIGHT), flowLayout);
            collectionView.BackgroundColor  = UIColor.Black;
            collectionView.Alpha            = 0.85f;
            collectionView.DecelerationRate = UIScrollView.DecelerationRateFast;
            collectionView.ShowsHorizontalScrollIndicator = false;
            collectionView.AlwaysBounceHorizontal         = true;
            collectionView.RegisterClassForSupplementaryView(typeof(PageHeader), UICollectionElementKindSection.Header, new NSString("pageHeader"));
            collectionView.AutoresizingMask = UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleWidth;
            this.View.AddSubview(collectionView);

            collectionView.BecomeFirstResponder();
        }