2016-12-08 19:09:02 +00:00
|
|
|
|
using System;
|
|
|
|
|
using CoreGraphics;
|
2016-12-10 19:12:10 +00:00
|
|
|
|
using Facebook.YogaKit.iOS;
|
2016-12-08 19:09:02 +00:00
|
|
|
|
using Foundation;
|
|
|
|
|
using UIKit;
|
|
|
|
|
|
|
|
|
|
namespace Facebook.Yoga.iOS.Test
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public partial class ViewController : UIViewController
|
|
|
|
|
{
|
|
|
|
|
protected ViewController(IntPtr handle) : base(handle)
|
|
|
|
|
{
|
|
|
|
|
// Note: this .ctor should not contain any initialization logic.
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void ViewDidLoad()
|
|
|
|
|
{
|
|
|
|
|
base.ViewDidLoad();
|
|
|
|
|
|
2016-12-10 19:12:10 +00:00
|
|
|
|
CreateViewHierarchy(View, View.Bounds.Size.Width, View.Bounds.Size.Height);
|
2016-12-08 19:09:02 +00:00
|
|
|
|
}
|
2016-12-10 19:12:10 +00:00
|
|
|
|
|
|
|
|
|
static void CreateViewHierarchy(UIView root, nfloat width, nfloat height)
|
2016-12-08 19:09:02 +00:00
|
|
|
|
{
|
2016-12-10 19:12:10 +00:00
|
|
|
|
root.BackgroundColor = UIColor.Red;
|
2016-12-08 19:09:02 +00:00
|
|
|
|
|
2016-12-10 19:12:10 +00:00
|
|
|
|
root.UsesYoga(true);
|
|
|
|
|
root.YogaWidth(width);
|
|
|
|
|
root.YogaWidth(height);
|
|
|
|
|
root.YogaAlignItems(YogaAlign.Center);
|
|
|
|
|
root.YogaJustify(YogaJustify.Center);
|
2016-12-08 19:09:02 +00:00
|
|
|
|
|
2016-12-10 19:12:10 +00:00
|
|
|
|
var child1 = new UIView { BackgroundColor = UIColor.Blue };
|
|
|
|
|
child1.YogaWidth(100);
|
|
|
|
|
child1.YogaHeight(100);
|
|
|
|
|
child1.UsesYoga(true);
|
2016-12-08 19:09:02 +00:00
|
|
|
|
|
2016-12-10 19:12:10 +00:00
|
|
|
|
var child2 = new UIView
|
2016-12-08 19:09:02 +00:00
|
|
|
|
{
|
2016-12-10 19:12:10 +00:00
|
|
|
|
BackgroundColor = UIColor.Green,
|
|
|
|
|
Frame = new CGRect { Size = new CGSize(200, 100) }
|
2016-12-08 19:09:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2016-12-10 19:12:10 +00:00
|
|
|
|
var child3 = new UIView
|
2016-12-08 19:09:02 +00:00
|
|
|
|
{
|
2016-12-10 19:12:10 +00:00
|
|
|
|
BackgroundColor = UIColor.Yellow,
|
|
|
|
|
Frame = new CGRect { Size = new CGSize(100, 100) }
|
2016-12-08 19:09:02 +00:00
|
|
|
|
};
|
|
|
|
|
|
2016-12-10 19:12:10 +00:00
|
|
|
|
child2.AddSubview(child3);
|
|
|
|
|
root.AddSubview(child1);
|
|
|
|
|
root.AddSubview(child2);
|
|
|
|
|
root.YogaApplyLayout();
|
2016-12-08 19:09:02 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override void DidReceiveMemoryWarning()
|
|
|
|
|
{
|
|
|
|
|
base.DidReceiveMemoryWarning();
|
|
|
|
|
// Release any cached data, images, etc that aren't in use.
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|