//https://developer.apple.com/library/ios/technotes/tn2154/_index.html //Pure approach public AutoLayoutContentView AddScrollView(string name, UIColor color) { var scrollView = new UIScrollView(); this.Add(scrollView); scrollView.Frame = new RectangleF(10, 10, 10, 10); // TODO: Is this still required? AutoLayoutContentView contentView = new AutoLayoutContentView(name, color, Font); contentView.Frame = new RectangleF(10, 10, 10, 10); // TODO: Is this still required? scrollView.Add(contentView); // Setup constraints scrollView.TranslatesAutoresizingMaskIntoConstraints = false; contentView.TranslatesAutoresizingMaskIntoConstraints = false; OurConstraints.ViewNames.Add(new NSString("PrivateScrollView")); OurConstraints.Views.Add(scrollView); int width = (int)this.Bounds.Size.Width; int height = (int)this.Bounds.Size.Height; AddConstraint("H:|[PrivateScrollView(" + width + ")]|"); AddConstraint("V:|[PrivateScrollView(>=" + height + ")]|"); AutoLayoutConstraints ScrollViewConstraints = new AutoLayout.AutoLayoutConstraints(); ScrollViewConstraints.ViewNames.Add(new NSString("PrivateContentView")); ScrollViewConstraints.Views.Add(contentView); AddConstraint("H:|[PrivateContentView(" + width + ")]|", scrollView, ScrollViewConstraints); AddConstraint("V:|[PrivateContentView(>=" + height + ")]|", scrollView, ScrollViewConstraints); OurConstraints.ViewNames.Add(new NSString(name)); OurConstraints.Views.Add(contentView); contentView.Parent = Parent; return(contentView); }
//https://developer.apple.com/library/ios/technotes/tn2154/_index.html //Pure approach public AutoLayoutContentView AddScrollView(string name, UIColor color) { var scrollView = new UIScrollView (); this.Add (scrollView); scrollView.Frame = new RectangleF (10, 10, 10, 10);// TODO: Is this still required? AutoLayoutContentView contentView = new AutoLayoutContentView (name, color, Font); contentView.Frame = new RectangleF (10, 10, 10, 10);// TODO: Is this still required? scrollView.Add (contentView); // Setup constraints scrollView.TranslatesAutoresizingMaskIntoConstraints = false; contentView.TranslatesAutoresizingMaskIntoConstraints = false; OurConstraints.ViewNames.Add (new NSString ("PrivateScrollView")); OurConstraints.Views.Add (scrollView); int width = (int)this.Bounds.Size.Width; int height = (int)this.Bounds.Size.Height; AddConstraint ("H:|[PrivateScrollView(" + width + ")]|"); AddConstraint ("V:|[PrivateScrollView(>=" + height + ")]|"); AutoLayoutConstraints ScrollViewConstraints = new AutoLayout.AutoLayoutConstraints (); ScrollViewConstraints.ViewNames.Add (new NSString ("PrivateContentView")); ScrollViewConstraints.Views.Add (contentView); AddConstraint ("H:|[PrivateContentView(" + width + ")]|", scrollView, ScrollViewConstraints); AddConstraint ("V:|[PrivateContentView(>=" + height + ")]|", scrollView, ScrollViewConstraints); OurConstraints.ViewNames.Add (new NSString (name)); OurConstraints.Views.Add (contentView); contentView.Parent = Parent; return contentView; }