public CategoriesCollectionViewSource(UICollectionView categories, NSString key) : base(categories, key) { categories.AddSubview(_tabIndicator = new UIView() .WithFrame(0, 0, 0, 2) .WithBackground(ThemeConfig.Categories.TabCell.Title.HighlightedTextColor.ToUIColor())); }
public static UIRefreshControl InjectRefreshControl(this UIViewController viewController, UICollectionView collectionView, EventHandler handler) { return(CoreUtility.ExecuteFunction("InjectRefreshControl", delegate() { UIRefreshControlDelayed refreshControl = new UIRefreshControlDelayed(); refreshControl.ScrollView = collectionView; refreshControl.AddTarget(handler, UIControlEvent.ValueChanged); collectionView.AddSubview(refreshControl); collectionView.AlwaysBounceVertical = true; return refreshControl; })); }
private void InitializeRefreshControl() { if (_refreshControl != null) { if (_tableView != null) { if (_tableController == null) { _tableController = new UITableViewController(); _tableController.TableView = _tableView; } _tableController.RefreshControl = _refreshControl; } if (_collectionView != null) { _collectionView.AddSubview(_refreshControl); } } }
/// <summary> /// Creates the cells and adds them to grid. /// Creates the buttons and adds them to cell. /// Creates the image from img path and adds them to button. /// </summary> public void CreateCells() { //gets the starting index for button ids using page and number of buttons per page nint btnIdCounter = (PageNum - 1) * AppData.ButtonsPerPage; for (int c = 0; c < Cols; c++) { for (int r = 0; r < Rows; r++) { //create cell CGRect cellFrame = new CGRect(c * CellW, r * CellH, CellW, CellH); UICollectionViewCell cell = new UICollectionViewCell(cellFrame); Grid.AddSubview(cell); //add cell to grid //create button and button data ButtonData theButtonData; CustomButton theButton = new CustomButton(); CGRect btnFrame = new CGRect(0 + (ButtonPadding / 2), 0 + (ButtonPadding / 2), CellW - (ButtonPadding), CellH - (ButtonPadding)); //retrives button data obj from list of buttons using id //returns null if no match theButtonData = AppData.Buttons.Find((x) => { return(x.ID == btnIdCounter); }); //if no button data obj existed with the button id if (theButtonData == null) //create default button data { //set the button data default values theButtonData = new ButtonData(); theButtonData.ID = (int)btnIdCounter; theButtonData.BorderColour = new BorderColourData() { Red = 0, Green = 0, Blue = 105 }; theButtonData.VidPath = "babyshark.m4v"; //theButtonData.ImgPath = "shark.jpg"; theButtonData.ImgPath = "defaultbuttonimg.png"; } //fill the button with the button data properties theButton.ID = (int)theButtonData.ID; theButton.BorderColour = UIColor.FromRGB(theButtonData.BorderColour.Red, theButtonData.BorderColour.Green, theButtonData.BorderColour.Blue).CGColor; theButton.VidPath = theButtonData.VidPath; theButton.ImgPath = theButtonData.ImgPath; //set the button styling and settings theButton.Layer.BorderColor = theButton.BorderColour; //set constant properties for every button theButton.Frame = btnFrame; //theButton.Layer.BorderWidth = ButtonBorderW; theButton.Layer.BorderWidth = AppData.BorderWidth; theButton.Layer.CornerRadius = ButtonCornerRadius; // var maskingShapeLayer = new CAShapeLayer() { Path = UIBezierPath.FromRoundedRect(theButton.Bounds, UIRectCorner.AllCorners, new CGSize(26, 26)).CGPath }; theButton.Layer.Mask = maskingShapeLayer; //add play vid function to button click theButton.TouchUpInside -= ButtonClickPlayVid; //fixes a saved button playing multiple times! theButton.TouchUpInside += ButtonClickPlayVid; //add button to cell cell.AddSubview(theButton); //create img CGRect imgFrame = new CGRect(0, 0, theButton.Bounds.Width, theButton.Bounds.Height); UIImageView img = new UIImageView(imgFrame); img.Image = new UIImage(theButton.ImgPath); //set the image to the button img path img.UserInteractionEnabled = false; //So user can still click the button img.Layer.CornerRadius = ButtonCornerRadius; img.ClipsToBounds = true; //enables corner radius on img //add img to button theButton.AddSubview(img); btnIdCounter++; //increments the button id counter for the next button } } }