Files
yoga/YogaKit/YogaKitSample/ViewController.m

61 lines
1.4 KiB
Mathematica
Raw Normal View History

2016-12-07 17:27:25 +00:00
/**
2016-12-07 17:41:50 +00:00
* Copyright 2014-present, Facebook, Inc.
2016-12-07 17:27:25 +00:00
* All rights reserved.
*
2016-12-07 17:41:50 +00:00
* This source code is licensed under the license found in the
* LICENSE-examples file in the root directory of this source tree.
2016-12-07 17:27:25 +00:00
*/
#import "ViewController.h"
#import <YogaKit/UIView+Yoga.h>
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
UIView *root = self.view;
root.backgroundColor = [UIColor redColor];
[root yg_setUsesYoga:YES];
[root yg_setWidth:self.view.bounds.size.width];
[root yg_setHeight:self.view.bounds.size.height];
[root yg_setAlignItems:YGAlignCenter];
[root yg_setJustifyContent:YGJustifyCenter];
UIView *child1 = [UIView new];
child1.backgroundColor = [UIColor blueColor];
[child1 yg_setUsesYoga:YES];
[child1 yg_setWidth:100];
[child1 yg_setHeight:100];
UIView *child2 = [UIView new];
child2.backgroundColor = [UIColor greenColor];
child2.frame = (CGRect) {
.size = {
.width = 200,
.height = 100,
}
};
UIView *child3 = [UIView new];
child3.backgroundColor = [UIColor yellowColor];
child3.frame = (CGRect) {
.size = {
.width = 100,
.height = 100,
}
};
[child2 addSubview:child3];
[root addSubview:child1];
[root addSubview:child2];
[root yg_applyLayout];
}
@end