private void CreateConstraints() { View.AddConstraints( _menu.AtTopOf(View), _menu.AtLeftOf(View), _menu.AtRightOf(View), _menu.Height().EqualTo(50), _album.Below(_menu), _album.AtBottomOf(View), _album.AtLeftOf(View), _album.AtRightOf(View) ); View.BringSubviewToFront(_menu); }
/// <inheritdoc /> public override void ViewDidLoad() { base.ViewDidLoad(); _menuView = new MenuView { BackgroundColor = Configuration.BackgroundColor, TranslatesAutoresizingMaskIntoConstraints = false, Opaque = false, AccessibilityLabel = "MenuView" }; _menuView.AddBottomBorder(UIColor.Black, 1); View.AddSubviews(_menuView); _libraryButton = new UIButton { TranslatesAutoresizingMaskIntoConstraints = false, LineBreakMode = UILineBreakMode.MiddleTruncation, HorizontalAlignment = UIControlContentHorizontalAlignment.Center, VerticalAlignment = UIControlContentVerticalAlignment.Center, ContentMode = UIViewContentMode.ScaleToFill, ContentEdgeInsets = new UIEdgeInsets(2, 2, 2, 2), AccessibilityLabel = "LibraryButton" }; _videoButton = new UIButton { TranslatesAutoresizingMaskIntoConstraints = false, LineBreakMode = UILineBreakMode.MiddleTruncation, HorizontalAlignment = UIControlContentHorizontalAlignment.Center, VerticalAlignment = UIControlContentVerticalAlignment.Center, ContentMode = UIViewContentMode.ScaleToFill, ContentEdgeInsets = new UIEdgeInsets(2, 2, 2, 2), AccessibilityLabel = "VideoButton" }; _cameraButton = new UIButton { TranslatesAutoresizingMaskIntoConstraints = false, LineBreakMode = UILineBreakMode.MiddleTruncation, HorizontalAlignment = UIControlContentHorizontalAlignment.Center, VerticalAlignment = UIControlContentVerticalAlignment.Center, ContentMode = UIViewContentMode.ScaleToFill, ContentEdgeInsets = new UIEdgeInsets(2, 2, 2, 2), AccessibilityLabel = "PhotoButton" }; View.AddSubviews(_libraryButton, _cameraButton); _cameraView = new CameraView { BackgroundColor = Configuration.BackgroundColor, TranslatesAutoresizingMaskIntoConstraints = false }; if (CellSize == CGSize.Empty) { CellSize = CalculateCellSize(); } AlbumView = new AlbumView(CellSize) { BackgroundColor = Configuration.BackgroundColor, TranslatesAutoresizingMaskIntoConstraints = false }; View.AddSubviews(_cameraView, AlbumView); View.AddConstraints( _menuView.Height().EqualTo(50), _menuView.AtTopOf(View), _menuView.AtLeftOf(View), _menuView.AtRightOf(View), AlbumView.AtLeftOf(View), AlbumView.AtRightOf(View), AlbumView.Below(_menuView), _cameraView.WithSameLeft(AlbumView), _cameraView.WithSameRight(AlbumView), _cameraView.Below(_menuView), _libraryButton.AtLeftOf(View), _libraryButton.AtBottomOf(View), _cameraButton.ToRightOf(_libraryButton), _cameraButton.AtBottomOf(View), _libraryButton.Height().EqualTo(45), _cameraButton.Height().EqualTo(45), _cameraButton.WithSameWidth(_libraryButton), AlbumView.Above(_libraryButton), _cameraView.Above(_libraryButton) ); View.BackgroundColor = Configuration.BackgroundColor; var albumImage = Configuration.AlbumImage ?? UIImage.FromBundle("ic_insert_photo"); var cameraImage = Configuration.CameraImage ?? UIImage.FromBundle("ic_photo_camera"); var videoImage = Configuration.VideoImage ?? UIImage.FromBundle("ic_videocam"); if (Configuration.TintIcons) { albumImage = albumImage?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); cameraImage = cameraImage?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); videoImage = videoImage?.ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate); } _libraryButton.SetImage(albumImage, UIControlState.Normal); _libraryButton.SetImage(albumImage, UIControlState.Highlighted); _libraryButton.SetImage(albumImage, UIControlState.Selected); _cameraButton.SetImage(cameraImage, UIControlState.Normal); _cameraButton.SetImage(cameraImage, UIControlState.Highlighted); _cameraButton.SetImage(cameraImage, UIControlState.Selected); _videoButton.SetImage(videoImage, UIControlState.Normal); _videoButton.SetImage(videoImage, UIControlState.Highlighted); _videoButton.SetImage(videoImage, UIControlState.Selected); if (Configuration.TintIcons) { _libraryButton.TintColor = Configuration.TintColor; _libraryButton.AdjustsImageWhenHighlighted = false; _cameraButton.TintColor = Configuration.TintColor; _cameraButton.AdjustsImageWhenHighlighted = false; _videoButton.TintColor = Configuration.TintColor; _videoButton.AdjustsImageWhenHighlighted = false; } _cameraButton.ClipsToBounds = true; _libraryButton.ClipsToBounds = true; _videoButton.ClipsToBounds = true; if (HasVideo) { _videoView = new VideoView { BackgroundColor = Configuration.BackgroundColor, TranslatesAutoresizingMaskIntoConstraints = false }; View.AddSubviews(_videoView, _videoButton); View.AddConstraints( _videoView.WithSameLeft(AlbumView), _videoView.WithSameRight(AlbumView), _videoView.Below(_menuView), _videoButton.ToRightOf(_cameraButton), _videoButton.AtBottomOf(View), _videoButton.AtRightOf(View), _videoButton.WithSameWidth(_cameraButton), _videoButton.Height().EqualTo(45), _videoView.Above(_libraryButton) ); } else { View.AddConstraints( _cameraButton.AtRightOf(View) ); } }