A Simple Demo to use MyLayout
suggest change- There is a container view S whose width is 100 and whose height wraps all of the subviews. There are four subviews, A, B, C, and D, arranged from top to bottom.
- Subview A’s left margin is 20% of the width of S, its right margin is 30% of the width of S, and its height is equal to the width of A.
- Subview B’s left margin is 40 and its width fills the remaining width of S. Its height is 40. Subview C’s width fills S, and its height is 40.
- Subview D’s right margin is 20, its width is 50% of the width of S, and its height is 40.
like the figure below:
MyLinearLayout *S = [MyLinearLayout linearLayoutWithOrientation:MyLayoutViewOrientation_Vert];
S.subviewSpace = 10;
S.widthSize.equalTo(@100);
UIView *A = [UIView new];
A.leftPos.equalTo(@0.2);
A.rightPos.equalTo(@0.3);
A.heightSize.equalTo(A.widthSize);
[S addSubview:A];
UIView *B = [UIView new];
B.leftPos.equalTo(@40);
B.widthSize.equalTo(@60);
B.heightSize.equalTo(@40);
[S addSubview:B];
UIView *C = [UIView new];
C.leftPos.equalTo(@0);
C.rightPos.equalTo(@0);
C.heightSize.equalTo(@40);
[S addSubview:C];
UIView *D = [UIView new];
D.rightPos.equalTo(@20);
D.widthSize.equalTo(S.widthSize).multiply(0.5);
D.heightSize.equalTo(@40);
[S addSubview:D];
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents