Created
February 25, 2014 08:34
-
-
Save Krumelur/9205106 to your computer and use it in GitHub Desktop.
EasyLayout Issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using MonoTouch.Foundation; | |
using MonoTouch.UIKit; | |
using System.Drawing; | |
using Praeclarum.UI; | |
namespace LayoutTest | |
{ | |
// The UIApplicationDelegate for the application. This class is responsible for launching the | |
// User Interface of the application, as well as listening (and optionally responding) to | |
// application events from iOS. | |
[Register ("AppDelegate")] | |
public partial class AppDelegate : UIApplicationDelegate | |
{ | |
// class-level declarations | |
UIWindow window; | |
// | |
// This method is invoked when the application has loaded and is ready to run. In this | |
// method you should instantiate the window, load the UI into it and then make the window | |
// visible. | |
// | |
// You have 17 seconds to return from this method, or iOS will terminate your application. | |
// | |
public override bool FinishedLaunching (UIApplication app, NSDictionary options) | |
{ | |
// create a new window instance based on the screen size | |
window = new UIWindow (UIScreen.MainScreen.Bounds); | |
// If you have defined a root view controller, set it here: | |
window.RootViewController = new FooController (); | |
// make the window visible | |
window.MakeKeyAndVisible (); | |
return true; | |
} | |
} | |
public class FooController : UIViewController | |
{ | |
public FooController() : base() | |
{ | |
} | |
public override void ViewDidLoad () | |
{ | |
this.View.BackgroundColor = UIColor.Yellow; | |
var topView = new UIView { | |
BackgroundColor = UIColor.Red | |
}; | |
var bottomView = new UIView { | |
BackgroundColor = UIColor.Blue | |
}; | |
var middleView = new UIView { | |
BackgroundColor = UIColor.Green | |
}; | |
this.View.AddSubviews (topView, middleView, bottomView); | |
// Why are the three views only 50% of the width of the screen?? | |
this.View.ConstrainLayout (() => | |
topView.Frame.Top == this.View.Bounds.Top && | |
topView.Frame.Height == 50 && | |
topView.Frame.Width == this.View.Bounds.Width && | |
bottomView.Frame.Top == (this.View.Bounds.Bottom - 50) && | |
bottomView.Frame.Height == 50 && | |
bottomView.Frame.Width == this.View.Bounds.Width && | |
middleView.Frame.Top == topView.Bounds.Bottom && | |
middleView.Frame.Bottom == bottomView.Bounds.Top && | |
middleView.Frame.Width == this.View.Bounds.Width | |
); | |
foreach(var c in this.View.Constraints) | |
{ | |
Console.WriteLine (c); | |
} | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment