Skip to content

Commit 5dbc94c

Browse files
committed
Release V1.4.0 Fix bug #42
1 parent b44aa5d commit 5dbc94c

16 files changed

+268
-129
lines changed

CHANGELOG.md

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

44
---
55

6+
## [V1.4.0](https://github.com/youngsoft/MyLinearLayout/releases/tag/1.4.0)(2017/6/16)
7+
8+
#### Added
9+
1. 添加了布局视图的新属性:`selected`,这个属性用来记录布局视图的选中和未选中状态
10+
2. 添加了布局视图删除所有子视图的快捷方法:`removeAllSubviews`
11+
12+
13+
#### Fixed
14+
1. 修复子视图宽高铺满布局视图并设置背景色时边界线不显示的问题。
15+
2. 修复了浮动布局`MyFloatLayout`中当子视图同时设置了`clearFloat``weight`的时候有可能尺寸显示不正确的问题。修复了[#BUG42](https://github.com/youngsoft/MyLinearLayout/issues/42)
16+
3. 修复了线性布局`MyLinearLayout`和框架布局`MyFrameLayout`同时设置左右或者上下边距和居中时的尺寸不正确的问题。
17+
4. 优化了位置和尺寸计算时的精度问题,老版本中有可能会出现比如12.99999999999998的场景,新版本将会减少这种情况的发生而直接设置为13. 同时对所有的布局中的大小比较进行了精度限制的优化。
18+
19+
20+
621
## [V1.3.9](https://github.com/youngsoft/MyLinearLayout/releases/tag/1.3.9)(2017/6/12)
722

823
#### Fixed

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.9"
19+
s.version = "1.4.0"
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.9" }
78+
s.source = { :git => "https://github.com/youngsoft/MyLinearLayout.git", :tag => "1.4.0" }
7979

8080

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

MyLayout/Lib/MyBaseLayout.h

+13
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,11 @@ typedef MyBorderline MyBorderLineDraw MYMETHODDEPRECATED("use MyBorderline to in
862862
@property(nonatomic, assign) BOOL priorAutoresizingMask;
863863

864864

865+
/**
866+
*设置是否选中状态。您可以用这个状态来记录布局的扩展属性。
867+
*/
868+
@property(nonatomic,getter=isSelected) BOOL selected; // default is NO may be used by some subclasses or by application
869+
865870

866871

867872
/**
@@ -874,6 +879,14 @@ typedef MyBorderline MyBorderLineDraw MYMETHODDEPRECATED("use MyBorderline to in
874879
@property(nonatomic,copy) void (^endLayoutBlock)();
875880

876881

882+
883+
884+
/**
885+
删除所有子视图的方便方法
886+
*/
887+
-(void)removeAllSubviews;
888+
889+
877890
/**
878891
*设置布局时的动画。并指定时间。这个函数是下面方法的简单实现:
879892

MyLayout/Lib/MyBaseLayout.m

+39-16
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ -(void)setViewLayoutCompleteBlock:(void (^)(MyBaseLayout *, UIView *))viewLayout
415415
-(CGRect)estimatedRect
416416
{
417417
CGRect rect = self.myFrame.frame;
418-
if (rect.size.width == CGFLOAT_MAX || rect.size.width == CGFLOAT_MAX)
418+
if (rect.size.width == CGFLOAT_MAX || rect.size.height == CGFLOAT_MAX)
419419
return self.frame;
420420
return rect;
421421
}
@@ -1087,6 +1087,11 @@ -(BOOL)hideSubviewReLayout
10871087
return NO;
10881088
}
10891089

1090+
-(void)removeAllSubviews
1091+
{
1092+
[self.subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
1093+
}
1094+
10901095

10911096
-(void)layoutAnimationWithDuration:(NSTimeInterval)duration
10921097
{
@@ -2086,13 +2091,13 @@ -(MyGravity)myGetSubviewVertGravity:(UIView*)sbv sbvsc:(UIView*)sbvsc vertGravit
20862091
sbvVertGravity = sbvVertAligement;
20872092
}
20882093

2089-
if (sbvsc.centerYPosInner.posVal != nil)
2094+
if (sbvsc.topPosInner.posVal != nil && sbvsc.bottomPosInner.posVal != nil)
20902095
{
2091-
sbvVertGravity = MyGravity_Vert_Center;
2096+
sbvVertGravity = MyGravity_Vert_Fill;
20922097
}
2093-
else if (sbvsc.topPosInner.posVal != nil && sbvsc.bottomPosInner.posVal != nil)
2098+
else if (sbvsc.centerYPosInner.posVal != nil)
20942099
{
2095-
sbvVertGravity = MyGravity_Vert_Fill;
2100+
sbvVertGravity = MyGravity_Vert_Center;
20962101
}
20972102
else if (sbvsc.topPosInner.posVal != nil)
20982103
{
@@ -2180,13 +2185,13 @@ -(MyGravity)myGetSubviewHorzGravity:(UIView*)sbv sbvsc:(UIView*)sbvsc horzGravit
21802185
sbvHorzGravity = sbvHorzAligement;
21812186
}
21822187

2183-
if (sbvsc.centerXPosInner.posVal != nil)
2188+
if (sbvsc.leadingPosInner.posVal != nil && sbvsc.trailingPosInner.posVal != nil)
21842189
{
2185-
sbvHorzGravity = MyGravity_Horz_Center;
2190+
sbvHorzGravity = MyGravity_Horz_Fill;
21862191
}
2187-
else if (sbvsc.leadingPosInner.posVal != nil && sbvsc.trailingPosInner.posVal != nil)
2192+
else if (sbvsc.centerXPosInner.posVal != nil)
21882193
{
2189-
sbvHorzGravity = MyGravity_Horz_Fill;
2194+
sbvHorzGravity = MyGravity_Horz_Center;
21902195
}
21912196
else if (sbvsc.leadingPosInner.posVal != nil)
21922197
{
@@ -3210,7 +3215,7 @@ -(void)setTopBorderline:(MyBorderline *)topBorderline
32103215
_topBorderline = topBorderline;
32113216

32123217
CAShapeLayer *borderLayer = _topBorderlineLayer;
3213-
[self myUpdateBorderLayer:&borderLayer withBorderline:_topBorderline];
3218+
[self updateBorderLayer:&borderLayer withBorderline:_topBorderline];
32143219
_topBorderlineLayer = borderLayer;
32153220

32163221
}
@@ -3223,7 +3228,7 @@ -(void)setLeadingBorderline:(MyBorderline *)leadingBorderline
32233228
_leadingBorderline = leadingBorderline;
32243229

32253230
CAShapeLayer *borderLayer = _leadingBorderlineLayer;
3226-
[self myUpdateBorderLayer:&borderLayer withBorderline:_leadingBorderline];
3231+
[self updateBorderLayer:&borderLayer withBorderline:_leadingBorderline];
32273232
_leadingBorderlineLayer = borderLayer;
32283233
}
32293234
}
@@ -3235,7 +3240,7 @@ -(void)setBottomBorderline:(MyBorderline *)bottomBorderline
32353240
_bottomBorderline = bottomBorderline;
32363241

32373242
CAShapeLayer *borderLayer = _bottomBorderlineLayer;
3238-
[self myUpdateBorderLayer:&borderLayer withBorderline:_bottomBorderline];
3243+
[self updateBorderLayer:&borderLayer withBorderline:_bottomBorderline];
32393244
_bottomBorderlineLayer = borderLayer;
32403245
}
32413246
}
@@ -3248,7 +3253,7 @@ -(void)setTrailingBorderline:(MyBorderline *)trailingBorderline
32483253
_trailingBorderline = trailingBorderline;
32493254

32503255
CAShapeLayer *borderLayer = _trailingBorderlineLayer;
3251-
[self myUpdateBorderLayer:&borderLayer withBorderline:_trailingBorderline];
3256+
[self updateBorderLayer:&borderLayer withBorderline:_trailingBorderline];
32523257
_trailingBorderlineLayer = borderLayer;
32533258
}
32543259

@@ -3289,7 +3294,7 @@ -(void)setRightBorderline:(MyBorderline *)rightBorderline
32893294

32903295

32913296

3292-
-(void)myUpdateBorderLayer:(CAShapeLayer**)ppLayer withBorderline:(MyBorderline*)borderline
3297+
-(void)updateBorderLayer:(CAShapeLayer**)ppLayer withBorderline:(MyBorderline*)borderline
32933298
{
32943299

32953300
if (borderline == nil)
@@ -3526,6 +3531,24 @@ BOOL _myCGFloatNotEqual(CGFloat f1, CGFloat f2)
35263531
#endif
35273532
}
35283533

3534+
BOOL _myCGFloatLess(CGFloat f1, CGFloat f2)
3535+
{
3536+
#if CGFLOAT_IS_DOUBLE == 1
3537+
return f2 - f1 > 1e-7;
3538+
#else
3539+
return f2 - f1 > 1e-4;
3540+
#endif
3541+
3542+
}
3543+
3544+
BOOL _myCGFloatGreat(CGFloat f1, CGFloat f2)
3545+
{
3546+
#if CGFLOAT_IS_DOUBLE == 1
3547+
return f1 - f2 > 1e-7;
3548+
#else
3549+
return f1 - f2 > 1e-4;
3550+
#endif
3551+
}
35293552

35303553
BOOL _myCGFloatLessOrEqual(CGFloat f1, CGFloat f2)
35313554
{
@@ -3567,8 +3590,8 @@ CGFloat _myRoundNumber(CGFloat f)
35673590
if (f == 0 || f == CGFLOAT_MAX || f == -CGFLOAT_MAX)
35683591
return f;
35693592

3570-
int fi = (int)f;
3571-
if (f == fi)
3593+
int fi = round(f);
3594+
if (_myCGFloatEqual(f, fi))
35723595
return fi;
35733596

35743597
//按精度四舍五入

0 commit comments

Comments
 (0)