private void SetupMainScroll() { mainScroll = CreateScrollView(); View.AddSubview(mainScroll); mainScroll.AutoPinEdgeToSuperviewEdge(ALEdge.Top); mainScroll.AutoPinEdgeToSuperviewEdge(ALEdge.Right); mainScroll.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom); mainScroll.AutoPinEdgeToSuperviewEdge(ALEdge.Left); }
private void SetupMainScroll() { mainScroll = new UIScrollView(); mainScroll.BackgroundColor = UIColor.White; mainScroll.ShowsVerticalScrollIndicator = true; mainScroll.ScrollEnabled = true; mainScroll.Bounces = true; mainScroll.DelaysContentTouches = true; mainScroll.CanCancelContentTouches = true; mainScroll.ContentMode = UIViewContentMode.ScaleToFill; mainScroll.UserInteractionEnabled = true; mainScroll.Opaque = true; mainScroll.ClipsToBounds = true; View.AddSubview(mainScroll); mainScroll.AutoPinEdgeToSuperviewEdge(ALEdge.Top); mainScroll.AutoPinEdgeToSuperviewEdge(ALEdge.Right); mainScroll.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom); mainScroll.AutoPinEdgeToSuperviewEdge(ALEdge.Left); }
void LayoutView() { // https://stackoverflow.com/questions/19036228/uiscrollview-scrollable-content-size-ambiguity/27227174#27227174 container = new UIScrollView(); var containerView = new UIView(); container.Frame = View.Bounds; container.BackgroundColor = UIColor.Clear; container.ContentSize = View.Bounds.Size; UIImage logoSmall = Constants.MaxResizeImage(UIImage.FromBundle(@"small_logo"), 250, 20); logoImageView = new UIImageView(logoSmall); logoImageView.ContentMode = UIViewContentMode.ScaleAspectFit; var textFieldBackgroundColor = Constants.UIColorFromRGB(0x4b4f63); usernameTextField = new UITextField { AutocapitalizationType = UITextAutocapitalizationType.None, BackgroundColor = textFieldBackgroundColor, TextColor = UIColor.White, KeyboardType = UIKeyboardType.Default, BorderStyle = UITextBorderStyle.RoundedRect }; //usernameTextField.Frame = new CGRect(0, 0, View.Bounds.Width - 20, 40); usernameTextField.AttributedPlaceholder = new NSAttributedString("Username", foregroundColor: UIColor.LightTextColor); usernameTextField.ShouldReturn = delegate { passwordTextField.BecomeFirstResponder(); return(true); }; passwordTextField = new UITextField { SecureTextEntry = true, BackgroundColor = textFieldBackgroundColor, TextColor = UIColor.White, BorderStyle = UITextBorderStyle.RoundedRect }; passwordTextField.AttributedPlaceholder = new NSAttributedString("Password", foregroundColor: UIColor.LightTextColor, font: UIFont.SystemFontOfSize(17f)); passwordTextField.ShouldReturn = delegate { passwordTextField.ResignFirstResponder(); return(true); }; var loginButtonBackgroundColor = Constants.UIColorFromRGB(0xff3333); loginButton = new UIButton(UIButtonType.RoundedRect); loginButton.BackgroundColor = loginButtonBackgroundColor; loginButton.SetTitle("LOG IN", UIControlState.Normal); loginButton.SetTitleColor(UIColor.White, UIControlState.Normal); loginButton.Font = UIFont.BoldSystemFontOfSize(24); loginButton.Layer.CornerRadius = 10f; loginButton.TouchUpInside += LoginButton_TouchUpInside; container.AddSubview(containerView); containerView.AddSubviews(new UIView[] { logoImageView, usernameTextField, passwordTextField, loginButton }); this.View.AddSubviews(new UIView[] { container }); #region Setup Autolayouts container.AutoPinEdgeToSuperviewEdge(ALEdge.Top, 0); container.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 0); container.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 0); container.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom, 0); containerView.AutoPinEdgeToSuperviewEdge(ALEdge.Top, 0); containerView.AutoPinEdgeToSuperviewEdge(ALEdge.Right, 0); containerView.AutoPinEdgeToSuperviewEdge(ALEdge.Left, 0); containerView.AutoPinEdgeToSuperviewEdge(ALEdge.Bottom, 0); containerView.AutoAlignAxisToSuperviewAxis(ALAxis.Horizontal); containerView.AutoAlignAxisToSuperviewAxis(ALAxis.Vertical); logoImageView.AutoPinEdgeToSuperviewEdge(ALEdge.Top, 120); logoImageView.AutoPinEdgeToSuperviewEdge(ALEdge.Left, (UIScreen.MainScreen.Bounds.Width - logoImageView.Bounds.Width) / 2); logoImageView.AutoPinEdgeToSuperviewEdge(ALEdge.Right, (UIScreen.MainScreen.Bounds.Width - logoImageView.Bounds.Width) / 2); logoImageView.AutoSetDimension(ALDimension.Height, 31); usernameTextField.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, logoImageView, 30); usernameTextField.AutoPinEdgeToSuperviewEdge(ALEdge.Left, Constants.WideMargin); usernameTextField.AutoPinEdgeToSuperviewEdge(ALEdge.Right, Constants.WideMargin); usernameTextField.AutoSetDimension(ALDimension.Height, 40); passwordTextField.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, usernameTextField, 12); passwordTextField.AutoPinEdgeToSuperviewEdge(ALEdge.Left, Constants.WideMargin); passwordTextField.AutoPinEdgeToSuperviewEdge(ALEdge.Right, Constants.WideMargin); passwordTextField.AutoSetDimension(ALDimension.Height, 40); //loginButton.Layer.BorderWidth = 1; //loginButton.Layer.BorderColor = UIColor.Blue.CGColor; loginButton.AutoPinEdge(ALEdge.Top, ALEdge.Bottom, passwordTextField, 20); loginButton.AutoPinEdgeToSuperviewEdge(ALEdge.Left, Constants.WideMargin); loginButton.AutoPinEdgeToSuperviewEdge(ALEdge.Right, Constants.WideMargin); loginButton.AutoSetDimension(ALDimension.Height, 50); #endregion }