Skip to content

Commit

Permalink
升级到1.7.0,修复BUG#90,解决issue#79
Browse files Browse the repository at this point in the history
  • Loading branch information
youngsoft committed May 16, 2019
1 parent b8fa4b5 commit ea9ce1b
Show file tree
Hide file tree
Showing 22 changed files with 750 additions and 66 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@
**MyLayout**的所有版本的变更日志都将会在这里记录.

---

## [V1.7.0](https://github.com/youngsoft/MyLinearLayout/releases/tag/1.7.0)(2019/05/16)
#### Added
1. 添加了对MyLayout的尺寸自适应和AutoLayout结合的能力。AutoLayout能使用和UILabel一样的MyLayout布局视图中的高度和宽度自适应的设置。具体需求见[issue#79](https://github.com/youngsoft/MyLinearLayout/issues/79)。这个问题的解决得到简化处理。新版本的能力让UITableViewCell的高度自适应的能力得到简化。具体的代码演示见[AllTest1ViewController](https://github.com/youngsoft/MyLinearLayout/blob/master/MyLayoutDemo/AllTest1ViewController.m),以及[AllTest12ViewController](https://github.com/youngsoft/MyLinearLayout/blob/master/MyLayoutDemo/AllTest12ViewController.m)中的详细介绍。

2. 添加了对RTL设置的即时生效的能力,您可通过方法`+[MyBaseLayout myUpArabicUI:(BOOL)isArabicUI inWindow:(UIWindow *)window
`来设置,具体的功能实现要感谢[LAnqxpp](https://github.com/LAnqxpp)的贡献。
#### Fixed
1. 修复了在完成布局后再对子视图设置约束时子视图约束不起作用的[BUG#90](https://github.com/youngsoft/MyLinearLayout/issues/90)。当代码中不对布局视图中的子视图设置任何约束时就会出现这个问题,这个问题涉及到所有布局。
2. 修复了相对布局可能会产生尺寸无限大的问题,尤其是当相对布局的高度为自适应,并且相对布局中同样存在着具有高度自适应的子布局视图的情况。


## [V1.6.1](https://github.com/youngsoft/MyLinearLayout/releases/tag/1.6.1)(2018/09/29)
#### Fixed
1. 修复对所有iPhoneX系列的设备的布局视图在设置padding的值为safeAreaMargin时的BUG。
Expand Down
2 changes: 1 addition & 1 deletion MyLayout.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Pod::Spec.new do |s|
#

s.name = "MyLayout"
s.version = "1.6.1"
s.version = "1.7.0"
s.summary = "MyLayout is an iOS UI framework integrates the functions with Android,AutoLayout,SizeClass,HTML CSS float and flexbox,UIView UITableView."

s.description = <<-DESC
Expand Down
27 changes: 21 additions & 6 deletions MyLayout.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@
444B71911F6A3E3F00331872 /* GLTest5ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 444B71901F6A3E3F00331872 /* GLTest5ViewController.m */; };
44EBDA8C1F619A6300B47CBD /* GLTest4ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 44EBDA8B1F619A6300B47CBD /* GLTest4ViewController.m */; };
44EBDA8E1F619C9000B47CBD /* GridLayoutDemo4.json in Resources */ = {isa = PBXBuildFile; fileRef = 44EBDA8D1F619C9000B47CBD /* GridLayoutDemo4.json */; };
467E63CC228C4D6F0065D080 /* AllTest12ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 467E63CB228C4D6F0065D080 /* AllTest12ViewController.m */; };
467E63CF228CDA660065D080 /* AllTest1TableViewCellForAutoLayout.m in Sources */ = {isa = PBXBuildFile; fileRef = 467E63CE228CDA660065D080 /* AllTest1TableViewCellForAutoLayout.m */; };
6740E1F820A52D9E00AFBC5A /* AllTest10ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 6740E1F620A52D9E00AFBC5A /* AllTest10ViewController.m */; };
6740E1FB20A52DA900AFBC5A /* AllTest10Model.m in Sources */ = {isa = PBXBuildFile; fileRef = 6740E1F920A52DA900AFBC5A /* AllTest10Model.m */; };
6740E1FE20A52DB100AFBC5A /* AllTest10HeaderView.m in Sources */ = {isa = PBXBuildFile; fileRef = 6740E1FC20A52DB000AFBC5A /* AllTest10HeaderView.m */; };
Expand Down Expand Up @@ -415,6 +417,10 @@
44EBDA8A1F619A6300B47CBD /* GLTest4ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLTest4ViewController.h; sourceTree = "<group>"; };
44EBDA8B1F619A6300B47CBD /* GLTest4ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GLTest4ViewController.m; sourceTree = "<group>"; };
44EBDA8D1F619C9000B47CBD /* GridLayoutDemo4.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = GridLayoutDemo4.json; sourceTree = "<group>"; };
467E63CA228C4D630065D080 /* AllTest12ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AllTest12ViewController.h; sourceTree = "<group>"; };
467E63CB228C4D6F0065D080 /* AllTest12ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AllTest12ViewController.m; sourceTree = "<group>"; };
467E63CD228CDA550065D080 /* AllTest1TableViewCellForAutoLayout.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AllTest1TableViewCellForAutoLayout.h; sourceTree = "<group>"; };
467E63CE228CDA660065D080 /* AllTest1TableViewCellForAutoLayout.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AllTest1TableViewCellForAutoLayout.m; sourceTree = "<group>"; };
6740E1F520A52D9D00AFBC5A /* AllTest10ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AllTest10ViewController.h; sourceTree = "<group>"; };
6740E1F620A52D9E00AFBC5A /* AllTest10ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AllTest10ViewController.m; sourceTree = "<group>"; };
6740E1F920A52DA900AFBC5A /* AllTest10Model.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AllTest10Model.m; sourceTree = "<group>"; };
Expand Down Expand Up @@ -670,6 +676,8 @@
6740E1F620A52D9E00AFBC5A /* AllTest10ViewController.m */,
20F0DFFB2111749A00CFCE8C /* AllTest11ViewController.h */,
20F0DFFC2111749A00CFCE8C /* AllTest11ViewController.m */,
467E63CA228C4D630065D080 /* AllTest12ViewController.h */,
467E63CB228C4D6F0065D080 /* AllTest12ViewController.m */,
18D3C9021EDF068200D3DE43 /* AllTestModel&View */,
);
name = IntegratedDemo;
Expand All @@ -680,6 +688,8 @@
children = (
18D3C9691EDF082800D3DE43 /* AllTest1TableViewCell.h */,
18D3C96A1EDF082800D3DE43 /* AllTest1TableViewCell.m */,
467E63CD228CDA550065D080 /* AllTest1TableViewCellForAutoLayout.h */,
467E63CE228CDA660065D080 /* AllTest1TableViewCellForAutoLayout.m */,
18D3C96B1EDF082800D3DE43 /* AllTest1TableViewHeaderFooterView.h */,
18D3C96C1EDF082800D3DE43 /* AllTest1TableViewHeaderFooterView.m */,
18D3C96D1EDF082800D3DE43 /* AllTest2TableViewCell.h */,
Expand Down Expand Up @@ -982,16 +992,17 @@
};
1840828C1B2C46E8003F378B = {
CreatedOnToolsVersion = 6.3.2;
DevelopmentTeam = 8EDMCH2Z7A;
DevelopmentTeam = BGQ8WB468K;
ProvisioningStyle = Automatic;
};
184082A51B2C46E8003F378B = {
CreatedOnToolsVersion = 6.3.2;
DevelopmentTeam = Q5MFLFRY64;
DevelopmentTeam = BGQ8WB468K;
TestTargetID = 1840828C1B2C46E8003F378B;
};
18B152301DEDDE5500AD7A1C = {
CreatedOnToolsVersion = 8.1;
DevelopmentTeam = BGQ8WB468K;
ProvisioningStyle = Automatic;
TestTargetID = 1840828C1B2C46E8003F378B;
};
Expand Down Expand Up @@ -1127,6 +1138,7 @@
182225D51E77E5930081AA4B /* MyLayoutSize.m in Sources */,
6740E20120A52DC100AFBC5A /* AllTest10Cell.m in Sources */,
18D3C93A1EDF07C000D3DE43 /* FLLTest2ViewController.m in Sources */,
467E63CF228CDA660065D080 /* AllTest1TableViewCellForAutoLayout.m in Sources */,
18D3C95A1EDF07F800D3DE43 /* FOLTest1ViewController.m in Sources */,
182225D01E77E5930081AA4B /* MyLayoutPos.m in Sources */,
18D3C98B1EDF084000D3DE43 /* AllTest7ViewController.m in Sources */,
Expand All @@ -1148,6 +1160,7 @@
18D3C9941EDF08F800D3DE43 /* YYFPSLabel.m in Sources */,
18D3C91D1EDF078200D3DE43 /* FLTest2ViewController.m in Sources */,
18D3C9661EDF080800D3DE43 /* TLTest1ViewController.m in Sources */,
467E63CC228C4D6F0065D080 /* AllTest12ViewController.m in Sources */,
6740E1FE20A52DB100AFBC5A /* AllTest10HeaderView.m in Sources */,
18D3C94A1EDF07E700D3DE43 /* PLTest2ViewController.m in Sources */,
205642881F4CFFB600E8BDDE /* MyBorderline.m in Sources */,
Expand Down Expand Up @@ -1456,7 +1469,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 8EDMCH2Z7A;
DEVELOPMENT_TEAM = BGQ8WB468K;
GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1";
INFOPLIST_FILE = "$(SRCROOT)/MyLayoutDemo/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
Expand All @@ -1478,7 +1491,7 @@
CODE_SIGN_IDENTITY = "iPhone Developer";
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 8EDMCH2Z7A;
DEVELOPMENT_TEAM = BGQ8WB468K;
GCC_PREPROCESSOR_DEFINITIONS = "";
INFOPLIST_FILE = "$(SRCROOT)/MyLayoutDemo/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
Expand All @@ -1496,7 +1509,7 @@
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
DEVELOPMENT_TEAM = Q5MFLFRY64;
DEVELOPMENT_TEAM = BGQ8WB468K;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
Expand All @@ -1517,7 +1530,7 @@
isa = XCBuildConfiguration;
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
DEVELOPMENT_TEAM = Q5MFLFRY64;
DEVELOPMENT_TEAM = BGQ8WB468K;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
Expand All @@ -1538,6 +1551,7 @@
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
DEBUG_INFORMATION_FORMAT = dwarf;
DEVELOPMENT_TEAM = BGQ8WB468K;
INFOPLIST_FILE = MyLayoutUITests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
Expand All @@ -1555,6 +1569,7 @@
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_SUSPICIOUS_MOVES = YES;
DEVELOPMENT_TEAM = BGQ8WB468K;
INFOPLIST_FILE = MyLayoutUITests/Info.plist;
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
Expand Down
2 changes: 1 addition & 1 deletion MyLayout/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.5.4</string>
<string>1.7.0</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSPrincipalClass</key>
Expand Down
142 changes: 141 additions & 1 deletion MyLayout/Lib/MyBaseLayout.m
Original file line number Diff line number Diff line change
Expand Up @@ -1770,6 +1770,146 @@ -(void)safeAreaInsetsDidChange
}
}


-(void)setNeedsLayout
{
[super setNeedsLayout];
if (!self.translatesAutoresizingMaskIntoConstraints)
{
if (self.wrapContentWidth || self.wrapContentHeight)
[self invalidateIntrinsicContentSize];
}
}

-(CGSize)intrinsicContentSize
{

CGSize sz = [super intrinsicContentSize];
if (self.translatesAutoresizingMaskIntoConstraints == NO && (self.wrapContentWidth || self.wrapContentHeight))
{
if (self.wrapContentWidth && self.wrapContentHeight)
{
sz = [self sizeThatFits:CGSizeZero];
}
else if (self.wrapContentWidth)
{
//动态宽度
NSLayoutConstraint *heightConstraint = nil;
for (NSLayoutConstraint *constraint in self.constraints)
{
if (constraint.firstItem == self && constraint.firstAttribute == NSLayoutAttributeHeight)
{
heightConstraint = constraint;
break;
}
}

if (heightConstraint == nil)
{
for (NSLayoutConstraint *constraint in self.superview.constraints)
{
if (constraint.firstItem == self && constraint.firstAttribute == NSLayoutAttributeHeight)
{
heightConstraint = constraint;
break;
}
}
}

if (heightConstraint != nil)
{
CGFloat dependHeight = UIViewNoIntrinsicMetric;
if ([heightConstraint.secondItem isKindOfClass:[UIView class]])
{
UIView *dependView = (UIView*)heightConstraint.secondItem;
CGRect dependViewRect = dependView.bounds;
if (heightConstraint.secondAttribute == NSLayoutAttributeHeight)
dependHeight = CGRectGetHeight(dependViewRect);
else if (heightConstraint.secondAttribute == NSLayoutAttributeWidth)
dependHeight = CGRectGetWidth(dependViewRect);
else
dependHeight = UIViewNoIntrinsicMetric;
}
else if (heightConstraint.secondItem == nil)
{
dependHeight = 0;
}
else
{
//do nothing...
}

if (dependHeight != UIViewNoIntrinsicMetric)
{
dependHeight *= heightConstraint.multiplier;
dependHeight += heightConstraint.constant;

sz.width = [self sizeThatFits:CGSizeMake(0, dependHeight)].width;
}
}
}
else
{
//动态高度
NSLayoutConstraint *widthConstraint = nil;
for (NSLayoutConstraint *constraint in self.constraints)
{
if (constraint.firstItem == self && constraint.firstAttribute == NSLayoutAttributeWidth)
{
widthConstraint = constraint;
break;
}
}

if (widthConstraint == nil)
{
for (NSLayoutConstraint *constraint in self.superview.constraints)
{
if (constraint.firstItem == self && constraint.firstAttribute == NSLayoutAttributeWidth)
{
widthConstraint = constraint;
break;
}
}
}

CGFloat dependWidth = UIViewNoIntrinsicMetric;
if (widthConstraint != nil)
{
if ([widthConstraint.secondItem isKindOfClass:[UIView class]])
{
UIView *dependView = (UIView*)widthConstraint.secondItem;
CGRect dependViewRect = dependView.bounds;
if (widthConstraint.secondAttribute == NSLayoutAttributeWidth)
dependWidth = CGRectGetWidth(dependViewRect);
else if (widthConstraint.secondAttribute == NSLayoutAttributeHeight)
dependWidth = CGRectGetHeight(dependViewRect);
else
dependWidth = UIViewNoIntrinsicMetric;
}
else if (widthConstraint.secondItem == nil)
{
dependWidth = 0;
}
else
{
//do nothing...
}

if (dependWidth != UIViewNoIntrinsicMetric)
{
dependWidth *= widthConstraint.multiplier;
dependWidth += widthConstraint.constant;
sz.height = [self sizeThatFits:CGSizeMake(dependWidth, 0)].height;
}
}
}
}

return sz;

}

-(void)layoutSubviews
{

Expand Down Expand Up @@ -1841,7 +1981,7 @@ -(void)layoutSubviews
CGPoint sbvOldCenter = sbv.center;

MyFrame *sbvmyFrame = sbv.myFrame;
UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame];
UIView *sbvsc = [sbv myCurrentSizeClassFrom:sbvmyFrame];

if (sbvmyFrame.leading != CGFLOAT_MAX && sbvmyFrame.top != CGFLOAT_MAX && !sbvsc.noLayout && !sbvsc.useFrame)
{
Expand Down
Loading

0 comments on commit ea9ce1b

Please sign in to comment.