//======================================================================================================================================== // PUBLIC METHODS //======================================================================================================================================== //======================================================================================================================================== // PRIVATE METHODS //======================================================================================================================================== /// <summary> /// Sets our constraints using the best thing to ever happen to auto layout: Anchors. The code should be self /// explanitory. As we want our views to stretch the full width and height of the screen we skip using margins /// except for the bottom view. /// </summary> private void setViewConstraints() { var margins = View.LayoutMarginsGuide; TopTableView.TopAnchor.ConstraintEqualTo(TopLayoutGuide.GetBottomAnchor()).Active = true; TopTableView.HeightAnchor.ConstraintEqualTo(iOS.TableCellHeight).Active = true; TopTableView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor).Active = true; TopTableView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor).Active = true; BottomTableView.TopAnchor.ConstraintEqualTo(TopTableView.BottomAnchor).Active = true; BottomTableView.BottomAnchor.ConstraintEqualTo(margins.BottomAnchor).Active = true; BottomTableView.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor).Active = true; BottomTableView.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor).Active = true; }
//======================================================================================================================================== // PUBLIC METHODS //======================================================================================================================================== //======================================================================================================================================== // PRIVATE METHODS //======================================================================================================================================== /// <summary> /// Sets our constraints using the best thing to ever happen to auto layout: Anchors. The code should be self /// explanitory. As we want our views to stretch the full width and height of the screen we skip using margins /// except for the bottom view. /// </summary> private void setViewConstraints() { var margins = View.LayoutMarginsGuide; tableViewTop.TopAnchor.ConstraintEqualTo(TopLayoutGuide.GetBottomAnchor()).Active = true; tableViewTop.HeightAnchor.ConstraintEqualTo(defaultCellHeight).Active = true; tableViewTop.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor).Active = true; tableViewTop.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor).Active = true; tableViewBottom.TopAnchor.ConstraintEqualTo(tableViewTop.BottomAnchor).Active = true; tableViewBottom.BottomAnchor.ConstraintEqualTo(margins.BottomAnchor).Active = true; tableViewBottom.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor).Active = true; tableViewBottom.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor).Active = true; }
public override void ViewDidLoad() { base.ViewDidLoad(); try { var window = UIApplication.SharedApplication.KeyWindow; nfloat topPadding = window.SafeAreaInsets.Top; nfloat bottomPadding = window.SafeAreaInsets.Bottom; View.BackgroundColor = UIColor.White; UIStackView container = new UIStackView(); View.AddSubview(container); container.Axis = UILayoutConstraintAxis.Vertical; container.TranslatesAutoresizingMaskIntoConstraints = false; container.Spacing = 15; container.LeadingAnchor.ConstraintEqualTo(View.LeadingAnchor).Active = true; container.TopAnchor.ConstraintEqualTo(TopLayoutGuide.GetBottomAnchor()).Active = true; container.TrailingAnchor.ConstraintEqualTo(View.TrailingAnchor).Active = true; container.BottomAnchor.ConstraintEqualTo(View.BottomAnchor).Active = true; UIStackView topBar = new UIStackView(); container.AddArrangedSubview(topBar); topBar.Axis = UILayoutConstraintAxis.Horizontal; topBar.Distribution = UIStackViewDistribution.FillProportionally; topBar.Alignment = UIStackViewAlignment.Center; topBar.Spacing = 14; topBar.BackgroundColor = UIColor.White; topBar.TranslatesAutoresizingMaskIntoConstraints = false; topBar.LeadingAnchor.ConstraintEqualTo(container.LeadingAnchor, 8).Active = true; topBar.TopAnchor.ConstraintEqualTo(TopLayoutGuide.GetBottomAnchor(), 17).Active = true; topBar.TrailingAnchor.ConstraintEqualTo(container.TrailingAnchor).Active = true; UIButton btnCloseWebView = new UIButton(UIButtonType.System); btnCloseWebView.Frame = new CGRect(btnCloseWebView.Frame.GetMidX(), btnCloseWebView.Frame.GetMidY(), 140, 140); //btnCloseWebView.CenterYAnchor.ConstraintEqualTo(topBar.CenterYAnchor).Active = true; btnCloseWebView.SetImage(UIImage.FromBundle("close.png"), UIControlState.Normal); btnCloseWebView.TintAdjustmentMode = UIViewTintAdjustmentMode.Automatic; btnCloseWebView.TintColor = UIColor.FromRGB(147, 16, 25); btnCloseWebView.Layer.CornerRadius = 5; topBar.AddArrangedSubview(btnCloseWebView); btnCloseWebView.LeadingAnchor.ConstraintEqualTo(topBar.LayoutMarginsGuide.LeadingAnchor).Active = true; btnCloseWebView.TouchUpInside += async(sender, e) => { AppServices._tcs.SetResult("close"); await DismissViewControllerAsync(true); }; var txtTitle = new UILabel(); txtTitle.Text = "Transfer Funds"; //txtTitle.CenterYAnchor.ConstraintEqualTo(topBar.CenterYAnchor).Active = true; txtTitle.Font = UIFont.FromName("PoppinsLatin-Bold", 17f); topBar.AddArrangedSubview(txtTitle); //Setup trustly //Webview pass in the correct trustly URL //Pass in the frame size of the view that will hold it (note: we will anchor the view later to be correct fullscreen). TrustlyWKWebView webView = new TrustlyWKWebView(URL, this.View.Frame); webView.WebViewNavigating += TrustlyView_Navigating; container.AddArrangedSubview(webView); webView.TranslatesAutoresizingMaskIntoConstraints = false; webView.LeadingAnchor.ConstraintEqualTo(container.LeadingAnchor).Active = true; webView.TrailingAnchor.ConstraintEqualTo(container.TrailingAnchor).Active = true; webView.BottomAnchor.ConstraintEqualTo(container.BottomAnchor, bottomPadding).Active = true; } catch { } }