Skip to content

Commit b6bde29

Browse files
author
@欧柏泉
committed
Release V1.3.2 : add new function and fix bug #30
1 parent 0309229 commit b6bde29

22 files changed

+755
-116
lines changed

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,21 @@
33

44
---
55

6+
## [V1.3.2](https://github.com/youngsoft/MyLinearLayout/releases/tag/1.3.2)(2017/1/20)
7+
8+
#### Added
9+
1. 流式布局`MyFlowLayout`添加了对分页滚动的支持,通过新增加的属性`pagedCount`来实现,这个属性只支持数量约束流式布局。`pagedCount``wrapContentHeight以及wrapContentWidth`配合使用能够实现各种方向上的分页滚动效果(具体见DEMO:FLLTest5ViewController)
10+
2. 线性布局`MyLinearLayout`中完全支持了所有子视图的高度等于宽度的设置的功能,以及在水平线性布局中添加了子宽度等于高度的功能。
11+
12+
#### Changed
13+
1. 流式布局`MyFlowLayout`中的子视图的widthDime,heightDime中可设置的相对类型尺寸的值的维多扩宽,不仅可以依赖兄弟视图,父视图,甚至还可以依赖别的任意的视图。
14+
15+
#### Fixed
16+
1. 修复了[#BUG30](https://github.com/youngsoft/MyLinearLayout/issues/30),主要原因是当计算出视图的尺寸为小于0时,而又将这个尺寸用来设置视图的bounds属性的尺寸时会调整bounds的origin部分而产生的BUG。具体展示是视图的位置产生了不正确的错误。
17+
18+
19+
20+
621
## [V1.3.1](https://github.com/youngsoft/MyLinearLayout/releases/tag/1.3.1)(2016/12/28)
722

823
#### Added

MyLayout.podspec

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ Pod::Spec.new do |s|
1616
#
1717

1818
s.name = "MyLayout"
19-
s.version = "1.3.1"
19+
s.version = "1.3.2"
2020
s.summary = "MyLayout is an iOS UI framework integrates the functions with Android,AutoLayout,SizeClass,HTML CSS float and flexbox,UIView UITableView."
2121

2222
s.description = <<-DESC
@@ -75,7 +75,7 @@ Pod::Spec.new do |s|
7575
# Supports git, hg, bzr, svn and HTTP.
7676
#
7777

78-
s.source = { :git => "https://github.com/youngsoft/MyLinearLayout.git", :tag => "1.3.1" }
78+
s.source = { :git => "https://github.com/youngsoft/MyLinearLayout.git", :tag => "1.3.2" }
7979

8080

8181
# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #

MyLayout.xcodeproj/project.pbxproj

+6
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/* Begin PBXBuildFile section */
1010
18014BA51C9079DA0088133B /* MyDimeScale.m in Sources */ = {isa = PBXBuildFile; fileRef = 18014BA41C9079DA0088133B /* MyDimeScale.m */; };
1111
181068371E0B4EA9000B9B86 /* AllTest8ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 181068361E0B4EA9000B9B86 /* AllTest8ViewController.m */; };
12+
181550681E2F75EA00329BFF /* FLLTest5ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 181550671E2F75EA00329BFF /* FLLTest5ViewController.m */; };
1213
181ECE631D570CA1007803BE /* YYFPSLabel.m in Sources */ = {isa = PBXBuildFile; fileRef = 181ECE5F1D570CA1007803BE /* YYFPSLabel.m */; };
1314
181ECE641D570CA1007803BE /* YYWeakProxy.m in Sources */ = {isa = PBXBuildFile; fileRef = 181ECE601D570CA1007803BE /* YYWeakProxy.m */; };
1415
181F97F51E079462004A9AE6 /* RLTest5ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 181F97F41E079462004A9AE6 /* RLTest5ViewController.m */; };
@@ -105,6 +106,8 @@
105106
18014BA41C9079DA0088133B /* MyDimeScale.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyDimeScale.m; sourceTree = "<group>"; };
106107
181068351E0B4EA9000B9B86 /* AllTest8ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AllTest8ViewController.h; sourceTree = "<group>"; };
107108
181068361E0B4EA9000B9B86 /* AllTest8ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AllTest8ViewController.m; sourceTree = "<group>"; };
109+
181550661E2F75DF00329BFF /* FLLTest5ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLLTest5ViewController.h; sourceTree = "<group>"; };
110+
181550671E2F75EA00329BFF /* FLLTest5ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLLTest5ViewController.m; sourceTree = "<group>"; };
108111
181ECE5F1D570CA1007803BE /* YYFPSLabel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YYFPSLabel.m; sourceTree = "<group>"; };
109112
181ECE601D570CA1007803BE /* YYWeakProxy.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YYWeakProxy.m; sourceTree = "<group>"; };
110113
181ECE611D570CA1007803BE /* YYWeakProxy.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YYWeakProxy.h; sourceTree = "<group>"; };
@@ -450,6 +453,8 @@
450453
1830A6081CD6EC4500FF6B57 /* FLLTest3ViewController.m */,
451454
18BCC5181D2D4879005081FF /* FLLTest4ViewController.h */,
452455
18BCC5191D2D4885005081FF /* FLLTest4ViewController.m */,
456+
181550661E2F75DF00329BFF /* FLLTest5ViewController.h */,
457+
181550671E2F75EA00329BFF /* FLLTest5ViewController.m */,
453458
);
454459
name = FlowLayoutDemo;
455460
sourceTree = "<group>";
@@ -774,6 +779,7 @@
774779
18BCC51A1D2D4885005081FF /* FLLTest4ViewController.m in Sources */,
775780
181F97F51E079462004A9AE6 /* RLTest5ViewController.m in Sources */,
776781
18D6843B1C4F421400A48BB4 /* MyFlowLayout.m in Sources */,
782+
181550681E2F75EA00329BFF /* FLLTest5ViewController.m in Sources */,
777783
18296B751C76D67F00273C3E /* FOLTest3ViewController.m in Sources */,
778784
18D684461C4F421400A48BB4 /* LLTest2ViewController.m in Sources */,
779785
18D684411C4F421400A48BB4 /* MyLinearLayout.m in Sources */,

MyLayout/FLLTest2ViewController.m

+1-1
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ - (IBAction)handleShrinkContent:(UISwitch *)sender {
8484

8585
//内容拉伸
8686
if (sender.isOn)
87-
self.flowLayout.gravity = MyMarginGravity_Horz_Fill; //对于内容填充的流时布局来说,averageArrange属性如果设置为YES表示里面的子视图的内容会自动的拉伸以便填充整个布局
87+
self.flowLayout.gravity = MyMarginGravity_Horz_Fill; //对于内容填充的流时布局来说,gravity属性如果设置为MyMarginGravity_Horz_Fill表示里面的子视图的内容会自动的拉伸以便填充整个布局
8888
else
8989
self.flowLayout.gravity = MyMarginGravity_None;
9090

MyLayout/FLLTest5ViewController.h

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// FLLTest5ViewController.h
3+
// MyLayout
4+
//
5+
// Created by oybq on 15/10/31.
6+
// Copyright (c) 2015年 YoungSoft. All rights reserved.
7+
//
8+
9+
#import <UIKit/UIKit.h>
10+
11+
@interface FLLTest5ViewController : UIViewController
12+
13+
@end

MyLayout/FLLTest5ViewController.m

+268
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
//
2+
// FLLTest5ViewController.m
3+
// MyLayout
4+
//
5+
// Created by oybq on 15/10/31.
6+
// Copyright (c) 2015年 YoungSoft. All rights reserved.
7+
//
8+
9+
#import "FLLTest5ViewController.h"
10+
#import "MyLayout.h"
11+
#import "CFTool.h"
12+
13+
@interface FLLTest5ViewController ()
14+
15+
16+
@end
17+
18+
@implementation FLLTest5ViewController
19+
20+
21+
-(void)loadView
22+
{
23+
/*
24+
这个例子主要是用来展示数量约束流式布局对分页滚动能力的支持。
25+
*/
26+
UIScrollView *scrollView = [UIScrollView new];
27+
scrollView.delaysContentTouches = NO; //因为里面也有滚动视图,优先处理子滚动视图的事件。
28+
self.view = scrollView;
29+
30+
MyLinearLayout *rootLayout = [MyLinearLayout linearLayoutWithOrientation:MyLayoutViewOrientation_Vert];
31+
rootLayout.backgroundColor = [UIColor whiteColor];
32+
rootLayout.myLeftMargin = rootLayout.myRightMargin = 0; //宽度和滚动视图保持一致。
33+
rootLayout.gravity = MyMarginGravity_Horz_Fill; //里面的所有子视图和布局视图宽度一致。
34+
[scrollView addSubview:rootLayout];
35+
36+
37+
//创建一个水平数量流式布局分页从左到右滚动
38+
[self createHorzPagingFlowLayout1:rootLayout];
39+
40+
//创建一个水平数量流式布局分页从上到下滚动的流式布局。
41+
[self createHorzPagingFlowLayout2:rootLayout];
42+
43+
//创建一个垂直数量流式布局分页从上到下滚动
44+
[self createVertPagingFlowLayout1:rootLayout];
45+
46+
//创建一个垂直数量流式布局分页从左到右滚动
47+
[self createVertPagingFlowLayout2:rootLayout];
48+
49+
50+
51+
52+
53+
}
54+
55+
- (void)viewDidLoad {
56+
[super viewDidLoad];
57+
// Do any additional setup after loading the view.
58+
59+
}
60+
61+
62+
- (void)didReceiveMemoryWarning {
63+
[super didReceiveMemoryWarning];
64+
// Dispose of any resources that can be recreated.
65+
}
66+
67+
#pragma mark -- Layout Construction
68+
69+
//添加所有测试子条目视图。
70+
-(void)addAllItemSubviews:(MyFlowLayout*)flowLayout
71+
{
72+
73+
for (int i = 0; i < 40; i++)
74+
{
75+
UILabel *label = [UILabel new];
76+
label.textAlignment = NSTextAlignmentCenter;
77+
label.backgroundColor = [CFTool color:random() % 14 + 1];
78+
label.text = [NSString stringWithFormat:@"%d",i];
79+
[flowLayout addSubview:label];
80+
81+
}
82+
83+
84+
}
85+
86+
87+
/**
88+
* 创建一个水平分页从左向右滚动的流式布局
89+
*/
90+
-(void)createHorzPagingFlowLayout1:(UIView*)rootLayout
91+
{
92+
UILabel *titleLabel = [UILabel new];
93+
titleLabel.text = @"水平流式布局分页从左往右滚动:➡︎";
94+
[titleLabel sizeToFit];
95+
[rootLayout addSubview:titleLabel];
96+
titleLabel.myTopMargin = 20;
97+
98+
//要开启分页功能,必须要将流式布局加入到一个滚动视图里面作为子视图!!!
99+
UIScrollView *scrollView = [UIScrollView new];
100+
scrollView.pagingEnabled = YES; //开启分页滚动模式!!您可以注释这句话看看非分页滚动的布局滚动效果。
101+
scrollView.myHeight = 200; //设置明确的高度为200,因为宽度已经由父线性布局的gravity属性确定了,所以不需要设置了。
102+
[rootLayout addSubview:scrollView];
103+
104+
105+
//建立一个水平数量约束流式布局:每列展示3个子视图,每页展示9个子视图,整体从左往右滚动。
106+
MyFlowLayout *flowLayout = [MyFlowLayout flowLayoutWithOrientation:MyLayoutViewOrientation_Horz arrangedCount:3];
107+
flowLayout.pagedCount = 9; //pagedCount设置为非0时表示开始分页展示的功能,这里表示每页展示9个子视图,这个数量必须是arrangedCount的倍数。
108+
flowLayout.wrapContentWidth = YES; //设置布局视图的宽度由子视图包裹,当水平流式布局的这个属性设置为YES,并和pagedCount搭配使用会产生分页从左到右滚动的效果。
109+
flowLayout.heightDime.equalTo(scrollView.heightDime); //因为是分页从左到右滚动,因此布局视图的高度必须设置为和父滚动视图相等。
110+
/*
111+
上面是实现一个水平流式布局分页且从左往右滚动的标准属性设置方法。
112+
*/
113+
114+
flowLayout.subviewHorzMargin = 10;
115+
flowLayout.subviewVertMargin = 10; //设置子视图的水平和垂直间距。
116+
flowLayout.padding = UIEdgeInsetsMake(5, 5, 5, 5); //布局视图的内边距设置!您可以注释掉这句话看看效果!如果设置内边距且也有分页时请将这个值设置和子视图间距相等。
117+
[scrollView addSubview:flowLayout];
118+
flowLayout.backgroundColor = [CFTool color:0];
119+
120+
[self addAllItemSubviews:flowLayout];
121+
122+
//获取流式布局的横屏size classes,并且设置当设备处于横屏时每页的数量由9个变为了18个。您可以注释掉这段代码,然后横竖屏切换看看效果。
123+
MyFlowLayout *flowLayoutSC = [flowLayout fetchLayoutSizeClass:MySizeClass_Landscape copyFrom:MySizeClass_wAny | MySizeClass_hAny];
124+
flowLayoutSC.pagedCount = 18;
125+
}
126+
127+
/**
128+
* 创建一个水平分页从上向下滚动的流式布局
129+
*/
130+
-(void)createHorzPagingFlowLayout2:(UIView*)rootLayout
131+
{
132+
UILabel *titleLabel = [UILabel new];
133+
titleLabel.text = @"水平流式布局分页从上往下滚动:⬇︎";
134+
[titleLabel sizeToFit];
135+
[rootLayout addSubview:titleLabel];
136+
titleLabel.myTopMargin = 20;
137+
138+
//要开启分页功能,必须要将流式布局加入到一个滚动视图里面作为子视图!!!
139+
UIScrollView *scrollView = [UIScrollView new];
140+
scrollView.pagingEnabled = YES; //开启分页滚动模式!!您可以注释这句话看看非分页滚动的布局滚动效果。
141+
scrollView.myHeight = 250; //设置明确的高度为250,因为宽度已经由父线性布局的gravity属性确定了,所以不需要设置了。
142+
[rootLayout addSubview:scrollView];
143+
144+
145+
//建立一个水平数量约束流式布局:每列展示3个子视图,每页展示9个子视图,整体从上往下滚动。
146+
MyFlowLayout *flowLayout = [MyFlowLayout flowLayoutWithOrientation:MyLayoutViewOrientation_Horz arrangedCount:3];
147+
flowLayout.pagedCount = 9; //pagedCount设置为非0时表示开始分页展示的功能,这里表示每页展示9个子视图,这个数量必须是arrangedCount的倍数。
148+
flowLayout.wrapContentHeight = YES; //设置布局视图的高度由子视图包裹,当水平流式布局的这个属性设置为YES,并和pagedCount搭配使用会产生分页从上到下滚动的效果。
149+
flowLayout.widthDime.equalTo(scrollView.widthDime); //因为是分页从左到右滚动,因此布局视图的宽度必须设置为和父滚动视图相等。
150+
/*
151+
上面是实现一个水平流式布局分页且从上往下滚动的标准属性设置方法。
152+
*/
153+
154+
flowLayout.subviewHorzMargin = 10;
155+
flowLayout.subviewVertMargin = 10; //设置子视图的水平和垂直间距。
156+
flowLayout.padding = UIEdgeInsetsMake(5, 5, 5, 5); //布局视图的内边距设置!您可以注释掉这句话看看效果!如果设置内边距且也有分页时请将这个值设置和子视图间距相等。
157+
[scrollView addSubview:flowLayout];
158+
flowLayout.backgroundColor = [CFTool color:0];
159+
160+
[self addAllItemSubviews:flowLayout];
161+
162+
//获取流式布局的横屏size classes,并且设置设备处于横屏时每页的数量由9个变为18个。您可以注释掉这段代码,然后横竖屏切换看看效果。
163+
MyFlowLayout *flowLayoutSC = [flowLayout fetchLayoutSizeClass:MySizeClass_Landscape copyFrom:MySizeClass_wAny | MySizeClass_hAny];
164+
flowLayoutSC.pagedCount = 18;
165+
166+
}
167+
168+
169+
/**
170+
* 创建一个垂直分页从上向下滚动的流式布局
171+
*/
172+
-(void)createVertPagingFlowLayout1:(UIView*)rootLayout
173+
{
174+
UILabel *titleLabel = [UILabel new];
175+
titleLabel.text = @"垂直流式布局分页从上往下滚动:⬇︎";
176+
[titleLabel sizeToFit];
177+
[rootLayout addSubview:titleLabel];
178+
titleLabel.myTopMargin = 20;
179+
180+
//要开启分页功能,必须要将流式布局加入到一个滚动视图里面作为子视图!!!
181+
UIScrollView *scrollView = [UIScrollView new];
182+
scrollView.pagingEnabled = YES; //开启分页滚动模式!!您可以注释这句话看看非分页滚动的布局滚动效果。
183+
scrollView.myHeight = 250; //设置明确的高度为250,因为宽度已经由父线性布局的gravity属性确定了,所以不需要设置了。
184+
[rootLayout addSubview:scrollView];
185+
186+
//建立一个垂直数量约束流式布局:每列展示3个子视图,每页展示9个子视图,整体从上往下滚动。
187+
MyFlowLayout *flowLayout = [MyFlowLayout flowLayoutWithOrientation:MyLayoutViewOrientation_Vert arrangedCount:3];
188+
flowLayout.pagedCount = 9; //pagedCount设置为非0时表示开始分页展示的功能,这里表示每页展示9个子视图,这个数量必须是arrangedCount的倍数。
189+
flowLayout.wrapContentHeight = YES; //设置布局视图的高度由子视图包裹,当垂直流式布局的这个属性设置为YES,并和pagedCount搭配使用会产生分页从上到下滚动的效果。
190+
flowLayout.widthDime.equalTo(scrollView.widthDime);
191+
/*
192+
上面是实现一个垂直流式布局分页且从上往下滚动的标准属性设置方法。
193+
*/
194+
195+
196+
flowLayout.subviewHorzMargin = 10;
197+
flowLayout.subviewVertMargin = 10; //设置子视图的水平和垂直间距。
198+
flowLayout.padding = UIEdgeInsetsMake(5, 5, 5, 5); //布局视图的内边距设置!您可以注释掉这句话看看效果!如果设置内边距且也有分页时请将这个值设置和子视图间距相等。
199+
[scrollView addSubview:flowLayout];
200+
flowLayout.backgroundColor = [CFTool color:0];
201+
202+
[self addAllItemSubviews:flowLayout];
203+
204+
//获取流式布局的横屏size classes,并且设置设备处于横屏时,每排数量由3个变为6个,每页的数量由9个变为18个。您可以注释掉这段代码,然后横竖屏切换看看效果。
205+
MyFlowLayout *flowLayoutSC = [flowLayout fetchLayoutSizeClass:MySizeClass_Landscape copyFrom:MySizeClass_wAny | MySizeClass_hAny];
206+
flowLayoutSC.arrangedCount = 6;
207+
flowLayoutSC.pagedCount = 18;
208+
209+
210+
211+
}
212+
213+
/**
214+
* 创建一个垂直分页从左向右滚动的流式布局
215+
*/
216+
-(void)createVertPagingFlowLayout2:(UIView*)rootLayout
217+
{
218+
UILabel *titleLabel = [UILabel new];
219+
titleLabel.text = @"垂直流式布局分页从左往右滚动:➡︎";
220+
[titleLabel sizeToFit];
221+
[rootLayout addSubview:titleLabel];
222+
titleLabel.myTopMargin = 20;
223+
224+
//要开启分页功能,必须要将流式布局加入到一个滚动视图里面作为子视图!!!
225+
UIScrollView *scrollView = [UIScrollView new];
226+
scrollView.pagingEnabled = YES; //开启分页滚动模式!!您可以注释这句话看看非分页滚动的布局滚动效果。
227+
scrollView.myHeight = 200; //设置明确的高度为200,因为宽度已经由父线性布局的gravity属性确定了,所以不需要设置了。
228+
[rootLayout addSubview:scrollView];
229+
230+
//建立一个垂直数量约束流式布局:每列展示3个子视图,每页展示9个子视图,整体从左往右滚动。
231+
MyFlowLayout *flowLayout = [MyFlowLayout flowLayoutWithOrientation:MyLayoutViewOrientation_Vert arrangedCount:3];
232+
flowLayout.pagedCount = 9; //pagedCount设置为非0时表示开始分页展示的功能,这里表示每页展示9个子视图,这个数量必须是arrangedCount的倍数。
233+
flowLayout.wrapContentWidth = YES; //设置布局视图的宽度由子视图包裹,当垂直流式布局的这个属性设置为YES,并和pagedCount搭配使用会产生分页从左到右滚动的效果。
234+
flowLayout.heightDime.equalTo(scrollView.heightDime);
235+
/*
236+
上面是实现一个垂直流式布局分页且从左往右滚动的标准属性设置方法。
237+
*/
238+
239+
240+
flowLayout.subviewHorzMargin = 10;
241+
flowLayout.subviewVertMargin = 10; //设置子视图的水平和垂直间距。
242+
flowLayout.padding = UIEdgeInsetsMake(5, 5, 5, 5); //布局视图的内边距设置!您可以注释掉这句话看看效果!如果设置内边距且也有分页时请将这个值设置和子视图间距相等。
243+
[scrollView addSubview:flowLayout];
244+
flowLayout.backgroundColor = [CFTool color:0];
245+
246+
[self addAllItemSubviews:flowLayout];
247+
248+
//获取流式布局的横屏size classes,并且设置设备处于横屏时,每排数量由3个变为6个,每页的数量由9个变为18个。您可以注释掉这段代码,然后横竖屏切换看看效果。
249+
MyFlowLayout *flowLayoutSC = [flowLayout fetchLayoutSizeClass:MySizeClass_Landscape copyFrom:MySizeClass_wAny | MySizeClass_hAny];
250+
flowLayoutSC.arrangedCount = 6;
251+
flowLayoutSC.pagedCount = 18;
252+
253+
}
254+
255+
256+
#pragma mark -- Handle Method
257+
258+
/*
259+
#pragma mark - Navigation
260+
261+
// In a storyboard-based application, you will often want to do a little preparation before navigation
262+
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
263+
// Get the new view controller using [segue destinationViewController].
264+
// Pass the selected object to the new view controller.
265+
}
266+
*/
267+
268+
@end

MyLayout/Info.plist

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>APPL</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>1.3.1</string>
18+
<string>1.3.2</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

0 commit comments

Comments
 (0)