Skip to content

Commit 6e93322

Browse files
author
@欧柏泉
committed
1.流式布局MyFlowLayout中的子视图添加了对weight属性的支持,流式布局中的weight属性表示的是剩余空间的占比。通过weight属性的使用,我们可以在很多用线性布局实现的布局,改用流式布局来完成,从而减少布局的嵌套。流式布局具有HTML中的Flex的特性。具体例子见FLLTest4ViewController
2.布局视图增加了子视图反序排列的功能属性:@Property(nonatomic, assign) BOOL reverseLayout; 这个属性可以按子视图添加的逆顺序进行界面布局。具体例子见:AllTest4ViewController 3.修正了浮动布局MyFloatLayout中weight计算的问题,由原先的减间距再乘比例改为先乘比例再减间距
1 parent caaa761 commit 6e93322

21 files changed

+852
-209
lines changed

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.2.1"
19+
s.version = "1.2.2"
2020
s.summary = "A powerful iOS view layout library, suitable for all kinds of screen size. Don't need to learn AutoLayout and SizeClass. "
2121

2222
s.description = <<-DESC
@@ -79,7 +79,7 @@ Pod::Spec.new do |s|
7979
# Supports git, hg, bzr, svn and HTTP.
8080
#
8181

82-
s.source = { :git => "https://github.com/youngsoft/MyLinearLayout.git", :tag => "1.2.1" }
82+
s.source = { :git => "https://github.com/youngsoft/MyLinearLayout.git", :tag => "1.2.2" }
8383

8484

8585
# ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #

MyLayout.xcodeproj/project.pbxproj

+6
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
189692701CF74E7E000A5B91 /* AllTest2TableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 1896926F1CF74E7E000A5B91 /* AllTest2TableViewCell.m */; };
2424
189692731CF74EA7000A5B91 /* AllTest1TableViewHeaderFooterView.m in Sources */ = {isa = PBXBuildFile; fileRef = 189692721CF74EA7000A5B91 /* AllTest1TableViewHeaderFooterView.m */; };
2525
189692761CF74EC5000A5B91 /* AllTestDataModel.m in Sources */ = {isa = PBXBuildFile; fileRef = 189692751CF74EC5000A5B91 /* AllTestDataModel.m */; };
26+
18BCC51A1D2D4885005081FF /* FLLTest4ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18BCC5191D2D4885005081FF /* FLLTest4ViewController.m */; };
2627
18CFFA2E1D0723970032A789 /* TLTest3ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18CFFA2D1D0723970032A789 /* TLTest3ViewController.m */; };
2728
18D684301C4F421400A48BB4 /* AllTest1ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18D683E81C4F421400A48BB4 /* AllTest1ViewController.m */; };
2829
18D684311C4F421400A48BB4 /* AllTest2ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 18D683EA1C4F421400A48BB4 /* AllTest2ViewController.m */; };
@@ -114,6 +115,8 @@
114115
189692721CF74EA7000A5B91 /* AllTest1TableViewHeaderFooterView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AllTest1TableViewHeaderFooterView.m; sourceTree = "<group>"; };
115116
189692741CF74EBB000A5B91 /* AllTestDataModel.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AllTestDataModel.h; sourceTree = "<group>"; };
116117
189692751CF74EC5000A5B91 /* AllTestDataModel.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AllTestDataModel.m; sourceTree = "<group>"; };
118+
18BCC5181D2D4879005081FF /* FLLTest4ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FLLTest4ViewController.h; sourceTree = "<group>"; };
119+
18BCC5191D2D4885005081FF /* FLLTest4ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FLLTest4ViewController.m; sourceTree = "<group>"; };
117120
18CFFA2C1D0723870032A789 /* TLTest3ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TLTest3ViewController.h; sourceTree = "<group>"; };
118121
18CFFA2D1D0723970032A789 /* TLTest3ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = TLTest3ViewController.m; sourceTree = "<group>"; };
119122
18D683E71C4F421400A48BB4 /* AllTest1ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = AllTest1ViewController.h; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
@@ -300,6 +303,8 @@
300303
186B83E21D094F11001CA155 /* FLLTest2ViewController.xib */,
301304
1830A6071CD6EC2F00FF6B57 /* FLLTest3ViewController.h */,
302305
1830A6081CD6EC4500FF6B57 /* FLLTest3ViewController.m */,
306+
18BCC5181D2D4879005081FF /* FLLTest4ViewController.h */,
307+
18BCC5191D2D4885005081FF /* FLLTest4ViewController.m */,
303308
18D683F51C4F421400A48BB4 /* FLTest1ViewController.h */,
304309
18D683F61C4F421400A48BB4 /* FLTest1ViewController.m */,
305310
18D683F71C4F421400A48BB4 /* FLTest2ViewController.h */,
@@ -540,6 +545,7 @@
540545
18D6844E1C4F421400A48BB4 /* RLTest2ViewController.m in Sources */,
541546
1890A22F1C6DD71600373B8B /* FLLTest2ViewController.m in Sources */,
542547
46D45B161C525FC400A8362C /* MyLayoutSizeClass.m in Sources */,
548+
18BCC51A1D2D4885005081FF /* FLLTest4ViewController.m in Sources */,
543549
18D6843B1C4F421400A48BB4 /* MyFlowLayout.m in Sources */,
544550
18296B751C76D67F00273C3E /* FOLTest3ViewController.m in Sources */,
545551
18D684461C4F421400A48BB4 /* LLTest2ViewController.m in Sources */,

MyLayout/AllTest4ViewController.m

+19
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ @interface AllTest4ViewController ()
1515

1616
@property(nonatomic, strong) MyLinearLayout *rootLayout;
1717

18+
@property(nonatomic,strong) NSMutableArray *containerLayouts;
19+
1820

1921
@end
2022

@@ -58,6 +60,8 @@ - (void)viewDidLoad {
5860
_rootLayout.wrapContentHeight = YES; //布局宽度和父视图一致,高度则由内容包裹。这是实现将布局视图加入滚动条视图并垂直滚动的标准方法。
5961
[scrollView addSubview:_rootLayout];
6062

63+
self.containerLayouts = [NSMutableArray new];
64+
6165
for (NSInteger i = 0; i < sections.count; i++)
6266
{
6367
//添加辅助视图
@@ -66,6 +70,7 @@ - (void)viewDidLoad {
6670
//添加单元格容器视图
6771
MyFlowLayout *cellContainerLayout = [self createCellContainerLayout:i + 2];
6872
cellContainerLayout.myBottomMargin = 10;
73+
[self.containerLayouts addObject:cellContainerLayout];
6974
[_rootLayout addSubview:cellContainerLayout];
7075

7176
//添加单元格视图
@@ -80,6 +85,9 @@ - (void)viewDidLoad {
8085
}
8186
}
8287

88+
89+
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Reverse" style:UIBarButtonItemStyleDone target:self action:@selector(handleReverse:)];
90+
8391
}
8492

8593
- (void)didReceiveMemoryWarning {
@@ -178,6 +186,17 @@ -(void)handleCellLayoutTap:(UIView*)sender
178186
[alertView show];
179187
}
180188

189+
-(void)handleReverse:(id)sender
190+
{
191+
//MyBaseLayout的属性reverseLayout可以将子视图按照添加的顺序逆序布局。
192+
193+
for (MyBaseLayout *layout in self.containerLayouts)
194+
{
195+
layout.reverseLayout = !layout.reverseLayout;
196+
[layout layoutAnimationWithDuration:0.3];
197+
}
198+
}
199+
181200
/*
182201
#pragma mark - Navigation
183202

MyLayout/Base.lproj/LaunchScreen.xib

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="14F27" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.XIB" version="3.0" toolsVersion="9531" systemVersion="15F34" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES">
33
<dependencies>
44
<deployment identifier="iOS"/>
55
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9529"/>

MyLayout/FLLTest4ViewController.h

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//
2+
// FLLTest4ViewController.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 FLLTest4ViewController : UIViewController
12+
13+
@end

0 commit comments

Comments
 (0)