-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Description
[self.view configureLayoutWithBlock:^(YGLayout * _Nonnull layout) {
layout.isEnabled = YES;
layout.flexDirection = YGFlexDirectionColumn;
}];
UIScrollView *scrollview = [[UIScrollView alloc] init];
[self.view addSubview:scrollview];
[scrollview configureLayoutWithBlock:^(YGLayout * _Nonnull layout) {
layout.isEnabled = YES;
layout.width = YGPercentValue(100);
layout.height = YGPercentValue(100);
layout.flexDirection = YGFlexDirectionColumn;
layout.overflow = YGOverflowScroll;
}];
UIView *view1 = [[UIView alloc] init];
[view1 setBackgroundColor:[UIColor redColor]];
[scrollview addSubview:view1];
[view1 configureLayoutWithBlock:^(YGLayout * _Nonnull layout) {
layout.isEnabled = YES;
layout.width = YGPercentValue(100);
layout.height = YGPercentValue(50);
}];
UIView *view2 = [[UIView alloc] init];
[view2 setBackgroundColor:[UIColor yellowColor]];
[scrollview addSubview:view2];
[view2 configureLayoutWithBlock:^(YGLayout * _Nonnull layout) {
layout.isEnabled = YES;
layout.width = YGPercentValue(100);
layout.height = YGPercentValue(50);
}];
UIView *view3 = [[UIView alloc] init];
[view3 setBackgroundColor:[UIColor purpleColor]];
[scrollview addSubview:view3];
[view3 configureLayoutWithBlock:^(YGLayout * _Nonnull layout) {
layout.isEnabled = YES;
layout.width = YGPercentValue(100);
layout.height = YGPercentValue(50);
}];
UIView *view4 = [[UIView alloc] init];
[view4 setBackgroundColor:[UIColor cyanColor]];
[scrollview addSubview:view4];
[view4 configureLayoutWithBlock:^(YGLayout * _Nonnull layout) {
layout.isEnabled = YES;
layout.width = YGPercentValue(100);
layout.height = YGPercentValue(50);
}];
[self.view.yoga applyLayoutPreservingOrigin:NO];
After call ApplyLayout, scrollview contentSize not correct