Skip to content

Commit 62a94df

Browse files
authored
Update README.zh.md
1 parent 37645c2 commit 62a94df

File tree

1 file changed

+31
-13
lines changed

1 file changed

+31
-13
lines changed

README.zh.md

+31-13
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ MyLayout是一套iOS界面视图布局框架。MyLayout的内核是基于对UIVi
2828
[http://www.jianshu.com/p/0c075f2fdab2](http://www.jianshu.com/p/0c075f2fdab2) 浮动布局
2929

3030

31+
### MyLayout的优势
32+
* MyLayout的实现内核是基于frame的设置,而不是对AutoLayout的封装。因此在使用上不会受到任何操作系统版本的限制。
33+
* 有文章表明用frame进行布局的性能要高于用AutoLayout进行布局的性能,尤其是当界面内视图数量增加时效果更加明显。
34+
* AutoLayout的思想是通过视图之间的约束依赖来完成布局,但是约束依赖的结果是造成视图之间的耦合性高而增大了界面更新的成本。而MyLayout则除了提供约束依赖外,还提供了根据视图添加顺序自动建立约束的功能,从而减少了这种显示依赖关系建立的问题,最终的结果是简化了布局的代码量,以及减少了布局更新时的代码修改量。
35+
* AutoLayout只是一种相对约束的布局,而MyLayout除了同时提供具有和AutoLayout相同能力的相对布局外、还提供了线性布局、框架布局、表格布局、流式布局、浮动布局、路径布局7大布局体系,你完全可以根据你的界面需求来选择一种最简易的布局容器来实现你的功能,同时MyLayout还支持Size classes的机制,以及提供了一些实现屏幕尺寸完美适配的方法。
36+
* MyLayout主要是一种通过代码进行布局的解决方案,但是框架一样可以支持和XIB以及SB结合布局的方式。并提供了视图隐藏和显示时会自动激发布局、布局视图的高度自适应(UITableviewCell动态高度)、标签云实现、左右内容宽度自适应、按比例分配尺寸和间距、整体停靠控制等等各种强大的功能。
37+
38+
39+
### AutoLayout和frame布局的性能比较
40+
![](http://upload-images.jianshu.io/upload_images/1432482-e7e8c36e1b790d92.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
41+
![](http://upload-images.jianshu.io/upload_images/1432482-69bddc21e9c9df5f.png?imageMogr2/auto-orient/strip%7CimageView2/2/w/1240)
42+
43+
参考的文章地址:[ http://floriankugler.com/2013/04/22/auto-layout-performance-on-ios/]( http://floriankugler.com/2013/04/22/auto-layout-performance-on-ios/)
44+
45+
46+
3147
## 演示效果图
3248

3349
![演示效果图](https://raw.githubusercontent.com/youngsoft/MyLinearLayout/master/MyLayout/layoutdemo1.gif)
@@ -49,38 +65,40 @@ MyLayout是一套iOS界面视图布局框架。MyLayout的内核是基于对UIVi
4965

5066
最终的效果图如下:
5167

52-
![demo](https://raw.githubusercontent.com/youngsoft/TangramKit/master/TangramKitDemo/Support Files/usagedemo.png)
68+
![demo](https://raw.githubusercontent.com/youngsoft/TangramKit/master/TangramKitDemo/Support%20Files/usagedemo.png)
5369

5470

5571
```objective-c
5672

57-
MyLinearLayout *S = [MyLinearLayout linearLayoutWithOrientation:MyLayoutViewOrientation_Vert];
73+
MyLinearLayout *S = [MyLinearLayout linearLayoutWithOrientation:MyLayoutViewOrientation_Vert];
5874
S.subviewMargin = 10;
59-
S.myWidth = 100;
60-
75+
   S.widthDime.equalTo(@100);
76+
   
6177
UIView *A = UIView.new;
62-
A.myLeftMargin = 0.2;
63-
A.myRightMargin = 0.3;
78+
A.leftPos.equalTo(@0.2);
79+
A.rightPos.equalTo(@0.3);
6480
A.heightDime.equalTo(A.widthDime);
6581
[S addSubview:A];
6682

6783
UIView *B = UIView.new;
68-
B.myLeftMargin = 40;
69-
B.myWidth = 60;
70-
B.myHeight = 40;
84+
B.leftPos.equalTo(@40);
85+
B.widthDime.equalTo(@60);
86+
B.heightDime.equalTo(@40);
7187
[S addSubview:B];
7288

7389
UIView *C = UIView.new;
74-
C.myLeftMargin = C.myRightMargin = 0;
75-
C.myHeight = 40;
90+
C.leftPos.equalTo(@0);
91+
C.rightPos.equalTo(@0);
92+
C.heightDime.equalTo(@40);
7693
[S addSubview:C];
7794

7895
UIView *D = UIView.new;
79-
D.myRightMargin = 20;
96+
D.rightPos.equalTo(@20);
8097
D.widthDime.equalTo(S.widthDime).multiply(0.5);
81-
D.myHeight = 40;
98+
D.heightDime.equalTo(@40);
8299
[S addSubview:D];
83100

101+
84102

85103
```
86104

0 commit comments

Comments
 (0)