From 6480263b3562a5bd81430e7d11d814f99a101914 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=AC=A7=E6=9F=8F=E6=B3=89?= Date: Mon, 23 Apr 2018 08:36:58 +0800 Subject: [PATCH] Release 1.5.1. The change is in the CHANGELOG.MD --- CHANGELOG.md | 12 + MyLayout.podspec | 2 +- MyLayout.xcodeproj/project.pbxproj | 6 + MyLayout/Lib/MyBaseLayout.h | 154 +--------- MyLayout/Lib/MyBaseLayout.m | 130 +-------- MyLayout/Lib/MyBorderline.h | 2 - MyLayout/Lib/MyFloatLayout.h | 9 - MyLayout/Lib/MyFloatLayout.m | 188 ++++++++++-- MyLayout/Lib/MyFlowLayout.h | 16 +- MyLayout/Lib/MyFlowLayout.m | 39 +-- MyLayout/Lib/MyFrameLayout.h | 20 -- MyLayout/Lib/MyFrameLayout.m | 3 +- MyLayout/Lib/MyGrid.h | 8 +- MyLayout/Lib/MyGridLayout.m | 6 +- MyLayout/Lib/MyLayout.h | 2 +- MyLayout/Lib/MyLayoutDef.h | 160 +++++----- MyLayout/Lib/MyLayoutInner.h | 6 +- MyLayout/Lib/MyLayoutMath.m | 3 +- MyLayout/Lib/MyLayoutPos.h | 6 - MyLayout/Lib/MyLayoutPos.m | 2 +- MyLayout/Lib/MyLayoutSize.h | 8 - MyLayout/Lib/MyLayoutSize.m | 4 +- MyLayout/Lib/MyLinearLayout.h | 17 -- MyLayout/Lib/MyLinearLayout.m | 42 +-- MyLayout/Lib/MyPathLayout.m | 8 +- MyLayout/Lib/MyRelativeLayout.h | 13 - MyLayout/Lib/MyRelativeLayout.m | 30 +- MyLayout/Lib/MyTableLayout.h | 19 +- MyLayout/Lib/MyTableLayout.m | 7 +- MyLayoutDemo/DetailViewController.m | 1 + MyLayoutDemo/FOLTest7ViewController.h | 16 + MyLayoutDemo/FOLTest7ViewController.m | 273 ++++++++++++++++++ MyLayoutDemo/Info.plist | 2 +- MyLayoutDemo/ViewController.m | 5 + .../zh-Hans.lproj/Localizable.strings | 1 + README.md | 2 +- README.zh.md | 2 +- 37 files changed, 596 insertions(+), 628 deletions(-) create mode 100644 MyLayoutDemo/FOLTest7ViewController.h create mode 100644 MyLayoutDemo/FOLTest7ViewController.m diff --git a/CHANGELOG.md b/CHANGELOG.md index ebac130..58cb5ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,18 @@ --- +## [V1.5.1](https://github.com/youngsoft/MyLinearLayout/releases/tag/1.5.1)(2018/04/23) + +#### Added +1. 添加了对浮动布局MyFloatLayout中的子视图的行或者列内对齐方式的设置,您可以借助子视图的myAlignment属性来设置行或者列内的对齐方式,具体的DEMO请参考:[FOLTest7ViewController](https://github.com/youngsoft/MyLinearLayout/blob/master/MyLayout/FOLTest7ViewController.m) 中的介绍。 +2. 将所有设置为过期的方法删除。 +3. 修正一些编译上的告警以及一些和Masonry公用时的一些问题。 +4. 修复方向旋转时有可能不调用`rotationToDeviceOrientationBlock`的问题。 +5. 修正一些注释上的提示。 +6. 将网友提交合并的代码一起发布新的版本。 + + + ## [V1.5.0](https://github.com/youngsoft/MyLinearLayout/releases/tag/1.5.0)(2017/10/9) #### Added diff --git a/MyLayout.podspec b/MyLayout.podspec index c820741..ad0ba17 100644 --- a/MyLayout.podspec +++ b/MyLayout.podspec @@ -16,7 +16,7 @@ Pod::Spec.new do |s| # s.name = "MyLayout" - s.version = "1.5.0" + s.version = "1.5.1" 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 diff --git a/MyLayout.xcodeproj/project.pbxproj b/MyLayout.xcodeproj/project.pbxproj index 617e68a..e193e1d 100644 --- a/MyLayout.xcodeproj/project.pbxproj +++ b/MyLayout.xcodeproj/project.pbxproj @@ -156,6 +156,7 @@ 208157C31F5A886400E945B6 /* MyLayoutDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 208157C11F5A886300E945B6 /* MyLayoutDelegate.m */; }; 208157C41F5A886400E945B6 /* MyLayoutDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 208157C11F5A886300E945B6 /* MyLayoutDelegate.m */; }; 20B46A8D1F8A79C300826372 /* layoutdemo8.gif in Resources */ = {isa = PBXBuildFile; fileRef = 20B46A8C1F8A79C300826372 /* layoutdemo8.gif */; }; + 20DCF333208C3BFB007A879B /* FOLTest7ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 20DCF332208C3BFB007A879B /* FOLTest7ViewController.m */; }; 20F783561F60399700BE5B31 /* GLTest3ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 20F783551F60399700BE5B31 /* GLTest3ViewController.m */; }; 4411977B1F6AE78E00C22557 /* GridLayoutDemo5.json in Resources */ = {isa = PBXBuildFile; fileRef = 4411977A1F6AE78E00C22557 /* GridLayoutDemo5.json */; }; 444B71911F6A3E3F00331872 /* GLTest5ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 444B71901F6A3E3F00331872 /* GLTest5ViewController.m */; }; @@ -383,6 +384,8 @@ 208157C01F5A886300E945B6 /* MyLayoutDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MyLayoutDelegate.h; sourceTree = ""; }; 208157C11F5A886300E945B6 /* MyLayoutDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MyLayoutDelegate.m; sourceTree = ""; }; 20B46A8C1F8A79C300826372 /* layoutdemo8.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = layoutdemo8.gif; sourceTree = ""; }; + 20DCF331208C3BEF007A879B /* FOLTest7ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FOLTest7ViewController.h; sourceTree = ""; }; + 20DCF332208C3BFB007A879B /* FOLTest7ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FOLTest7ViewController.m; sourceTree = ""; }; 20F783541F60398C00BE5B31 /* GLTest3ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GLTest3ViewController.h; sourceTree = ""; }; 20F783551F60399700BE5B31 /* GLTest3ViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GLTest3ViewController.m; sourceTree = ""; }; 4411977A1F6AE78E00C22557 /* GridLayoutDemo5.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = GridLayoutDemo5.json; sourceTree = ""; }; @@ -587,6 +590,8 @@ 18D3C9571EDF07F800D3DE43 /* FOLTest5ViewController.m */, 18D3C9581EDF07F800D3DE43 /* FOLTest6ViewController.h */, 18D3C9591EDF07F800D3DE43 /* FOLTest6ViewController.m */, + 20DCF331208C3BEF007A879B /* FOLTest7ViewController.h */, + 20DCF332208C3BFB007A879B /* FOLTest7ViewController.m */, ); name = FloatLayoutDemo; sourceTree = ""; @@ -1100,6 +1105,7 @@ 18D3C9171EDF074900D3DE43 /* LLTest7ViewController.m in Sources */, 18D3C98A1EDF084000D3DE43 /* AllTest6ViewController.m in Sources */, 18D3C9111EDF074900D3DE43 /* LLTest1ViewController.m in Sources */, + 20DCF333208C3BFB007A879B /* FOLTest7ViewController.m in Sources */, 18D3C93E1EDF07C000D3DE43 /* FLLTest6ViewController.m in Sources */, 200A26D91FA8A90300B06E7B /* AllTest9ViewController.m in Sources */, 18D3C9281EDF07A700D3DE43 /* RLTest1ViewController.m in Sources */, diff --git a/MyLayout/Lib/MyBaseLayout.h b/MyLayout/Lib/MyBaseLayout.h index 99717fa..c77f964 100644 --- a/MyLayout/Lib/MyBaseLayout.h +++ b/MyLayout/Lib/MyBaseLayout.h @@ -554,7 +554,7 @@ /** - 指定子在布局视图上的对齐方式,默认是None表示未指定,这个属性目前只支持框架布局,线性布局,流式布局下的属性设置。 + 指定子在布局视图上的对齐方式,默认是None表示未指定,这个属性目前只支持框架布局,线性布局,流式布局,浮动布局下的属性设置。 1. 在框架布局中支持上、中、下、垂直拉伸和左、中、右、水平拉伸8个设置 @@ -562,9 +562,9 @@ 3. 在水平线性布局中只支持上、中、下、垂直拉伸对齐。(如果父布局视图设置了gravity,子视图设置了这个属性则这个属性优先级最高) - 4. 在垂直流式布局中用来设置一行内的上、中、下、垂直拉伸对齐。(如果父布局视图设置了arrangedGravity,子视图设置了这个属性则这个属性优先级最高) + 4. 在垂直流式布局和垂直浮动布局中用来设置一行内的上、中、下、垂直拉伸对齐。(如果流式父布局视图设置了arrangedGravity,子视图设置了这个属性则这个属性优先级最高) - 5. 在水平流式布局中用来设置一列内的左、中、右、水平拉伸对齐。(如果父布局视图设置了arrangedGravity,子视图时设置了这个属性则这个属性优先级最高) + 5. 在水平流式布局和水平浮动布局中用来设置一列内的左、中、右、水平拉伸对齐。(如果流式父布局视图设置了arrangedGravity,子视图时设置了这个属性则这个属性优先级最高) */ @property(nonatomic, assign) MyGravity myAlignment; @@ -609,69 +609,6 @@ -(instancetype)fetchLayoutSizeClass:(MySizeClass)sizeClass copyFrom:(MySizeClass)srcSizeClass; -@end - - -@interface UIView(MyLayoutExtDeprecated) - -/** - * 过期的位置和尺寸设置方法,老版本中带Margin后缀就明确为了边距的概念,但是这个和属性定义的概念是不一致的,位置即可表示边距也可以表示间距。所以这些方法将设置为过期。您可以在相应的位置定义宏:#define MY_USEOLDMETHODNOWARNING = 1 则不会出现老方法告警,不过不建议这么做。 - */ - - -/** - *过期属性,请用myLeft - */ -@property(nonatomic, assign) CGFloat myLeftMargin MYMETHODDEPRECATED("use myLeft to instead"); - -/** - *过期属性,请用myTop - */ -@property(nonatomic, assign) CGFloat myTopMargin MYMETHODDEPRECATED("use myTop to instead"); - -/** - *过期属性,请用myRight - */ -@property(nonatomic, assign) CGFloat myRightMargin MYMETHODDEPRECATED("use myRight to instead"); - -/** - *过期属性,请用myBottom - */ -@property(nonatomic, assign) CGFloat myBottomMargin MYMETHODDEPRECATED("use myBottom to instead"); - -/** - *过期属性,请用myCenterX - */ -@property(nonatomic, assign) CGFloat myCenterXOffset MYMETHODDEPRECATED("use myCenterX to instead"); - -/** - *过期属性,请用myCenterY - */ -@property(nonatomic, assign) CGFloat myCenterYOffset MYMETHODDEPRECATED("use myCenterY to instead"); - -/** - *过期属性,请用myCenter - */ -@property(nonatomic, assign) CGPoint myCenterOffset MYMETHODDEPRECATED("use myCenter to instead"); - -/** - *过期属性,请用widthSize - */ -@property(nonatomic, readonly) MyLayoutSize *widthDime MYMETHODDEPRECATED("use widthSize to instead"); - -/** - *过期属性,请用heightSize - */ -@property(nonatomic, readonly) MyLayoutSize *heightDime MYMETHODDEPRECATED("use heightSize to instead"); - - -/** - *过期属性,请用wrapContentHeight - */ -@property(nonatomic, assign, getter=isFlexedHeight) BOOL flexedHeight MYMETHODDEPRECATED("use wrapContentHeight to instead"); - - - @end @@ -686,16 +623,11 @@ */ @interface MyBaseLayout : UIView -#if UIKIT_DEFINE_AS_PROPERTIES - /** 用于实现对阿拉伯国家的布局适配。对于非阿拉伯国家来说,界面布局都是默认从左到右排列。而对于阿拉伯国家来说界面布局则默认是从右往左排列。默认这个属性是NO,您可以将这个属性设置为YES,这样布局里面的所有视图都将从右到左进行排列布局。如果您需要考虑国际化布局的问题,那么您应该用leadingPos来表示头部的位置,而用trailingPos来表示尾部的位置,这样当布局方向是LTR时那么leadingPos就表示的是左边而trailingPos则表示的是右边;而当布局方向是RTL时那么leadingPos表示的是右边而trailingPos则表示的是左边。如果您的界面布局不会考虑到国际化以及不需要考虑RTL时那么您可以用leftPos和rightPos来表示左右而不需要用leadingPos和trailingPos。 */ @property(class, nonatomic, assign) BOOL isRTL; -#else -+(BOOL)isRTL; -+(void)setIsRTL:(BOOL)isRTL; -#endif + /* 布局视图里面的padding属性用来设置布局视图的内边距。内边距是指布局视图里面的子视图离自己距离。外边距则是视图与父视图之间的距离。 @@ -1054,82 +986,4 @@ @end -@interface MyBaseLayout(MyBaseLayoutDeprecated) - -/** - *过期方法,对于间距统一用space来描述,而边距用margin来描述。 - *原先子视图之间的间距属性的命名规范不合理,所以这里将原先的设置间距的属性设置为过期。这里也和TangramKit中的命名统一。 - *您可以在相应的位置定义宏:#define MY_USEOLDMETHODNOWARNING = 1 则不会出现老方法告警,不过不建议这么做。 - */ - -/** -*过期属性,请用subviewVSpace -*/ -@property(nonatomic ,assign, getter=subviewVSpace, setter=setSubviewVSpace:) CGFloat subviewVertMargin MYMETHODDEPRECATED("use subviewVSpace to instead"); - -/** - *过期属性,请用subviewHSpace - */ -@property(nonatomic, assign, getter=subviewHSpace, setter=setSubviewHSpace:) CGFloat subviewHorzMargin MYMETHODDEPRECATED("use subviewHSpace to instead"); - -/** - *过期属性,请用subviewSpace - */ -@property(nonatomic, assign, getter=subviewSpace, setter=setSubviewSpace:) CGFloat subviewMargin MYMETHODDEPRECATED("use subviewSpace to instead"); - -/** - *过期方法, 原先对边界线命名BorderLine不符合规则,Borderline是一个单词不是一个词组。这里也和TangramKit中的命名统一。 - */ - -/** - *过期属性,请用leftBorderline - */ -@property(nonatomic, strong, getter=leftBorderline, setter=setLeftBorderline:) MyBorderline *leftBorderLine MYMETHODDEPRECATED("use leftBorderline to instead"); - -/** - *过期属性,请用rightBorderline - */ -@property(nonatomic, strong, getter=rightBorderline, setter=setRightBorderline:) MyBorderline *rightBorderLine MYMETHODDEPRECATED("use rightBorderline to instead"); - -/** - *过期属性,请用topBorderline - */ -@property(nonatomic, strong, getter=topBorderline, setter=setTopBorderline:) MyBorderline *topBorderLine MYMETHODDEPRECATED("use topBorderline to instead"); - -/** - *过期属性,请用bottomBorderline - */ -@property(nonatomic, strong, getter=bottomBorderline, setter=setBottomBorderline:) MyBorderline *bottomBorderLine MYMETHODDEPRECATED("use bottomBorderline to instead"); - -/** - *过期属性,请用boundBorderline - */ -@property(nonatomic, strong, getter=boundBorderline, setter=setBoundBorderline:) MyBorderline *boundBorderLine MYMETHODDEPRECATED("use boundBorderline to instead"); - -/** - *过期属性,请用intelligentBorderline - */ -@property(nonatomic, strong, getter=intelligentBorderline, setter=setIntelligentBorderline:) MyBorderline *IntelligentBorderLine MYMETHODDEPRECATED("use intelligentBorderline to instead"); - -/** - *过期属性,请用notUseIntelligentBorderline - */ -@property(nonatomic, assign, getter=notUseIntelligentBorderline, setter=setNotUseIntelligentBorderline:) BOOL notUseIntelligentBorderLine MYMETHODDEPRECATED("use notUseIntelligentBorderline to instead"); - - -/** - *这个属性在新版本将失效并且无任何意义了。如果想让子视图隐藏时是否继续占据位置则请参考使用子视图的myVisibility属性来进行单独设置。 - */ -@property(nonatomic, assign) BOOL hideSubviewReLayout MYMETHODDEPRECATED("this property was invalid, please use subview's myVisibility to instead"); - - -/** - *过期方法。请用sizeThatFits方法来代替。 - */ --(CGRect)estimateLayoutRect:(CGSize)size MYMETHODDEPRECATED("this method was invalid, please use sizeThatFits: to instead"); --(CGRect)estimateLayoutRect:(CGSize)size inSizeClass:(MySizeClass)sizeClass MYMETHODDEPRECATED("this method was invalid, please use sizeThatFits:inSizeClass: to instead"); - - -@end - diff --git a/MyLayout/Lib/MyBaseLayout.m b/MyLayout/Lib/MyBaseLayout.m index ebd1772..601a90b 100644 --- a/MyLayout/Lib/MyBaseLayout.m +++ b/MyLayout/Lib/MyBaseLayout.m @@ -462,111 +462,6 @@ -(instancetype)fetchLayoutSizeClass:(MySizeClass)sizeClass copyFrom:(MySizeClass -@end - -@implementation UIView(MyLayoutExtDeprecated) - - - - --(CGFloat)myLeftMargin -{ - return self.myLeft; -} - --(void)setMyLeftMargin:(CGFloat)myLeftMargin -{ - self.myLeft = myLeftMargin; -} - --(CGFloat)myTopMargin -{ - return self.myTop; -} - --(void)setMyTopMargin:(CGFloat)myTopMargin -{ - self.myTop = myTopMargin; -} - --(CGFloat)myRightMargin -{ - return self.myRight; -} - --(void)setMyRightMargin:(CGFloat)myRightMargin -{ - self.myRight = myRightMargin; -} - --(CGFloat)myBottomMargin -{ - return self.myBottom; -} - --(void)setMyBottomMargin:(CGFloat)myBottomMargin -{ - self.myBottom = myBottomMargin; -} - --(MyLayoutSize*)widthDime -{ - return self.widthSize; -} - - - --(MyLayoutSize*)heightDime -{ - return self.heightSize; -} - - --(CGFloat)myCenterXOffset -{ - return self.myCenterX; -} - --(void)setMyCenterXOffset:(CGFloat)myCenterXOffset -{ - self.myCenterX = myCenterXOffset; -} - --(CGFloat)myCenterYOffset -{ - return self.myCenterY; -} - --(void)setMyCenterYOffset:(CGFloat)myCenterYOffset -{ - self.myCenterY = myCenterYOffset; -} - - --(CGPoint)myCenterOffset -{ - return self.myCenter; -} - --(void)setMyCenterOffset:(CGPoint)myCenterOffset -{ - self.myCenter = myCenterOffset; -} - - - --(void)setFlexedHeight:(BOOL)flexedHeight -{ - self.wrapContentHeight = flexedHeight; -} - --(BOOL)isFlexedHeight -{ - return self.wrapContentHeight; -} - - - @end @@ -805,6 +700,9 @@ -(void)dealloc _rotationToDeviceOrientationBlock = nil; } +#pragma mark -- Public Methods + + +(BOOL)isRTL { return [MyViewSizeClass isRTL]; @@ -815,7 +713,6 @@ +(void)setIsRTL:(BOOL)isRTL [MyViewSizeClass setIsRTL:isRTL]; } -#pragma mark -- Public Method -(CGFloat)topPadding @@ -1444,7 +1341,7 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(UIView*)object chan } -#pragma mark -- Override Method +#pragma mark -- Override Methods @@ -2184,24 +2081,7 @@ -(void)layoutSubviews } -#pragma mark -- Deprecated Method - --(CGRect)estimateLayoutRect:(CGSize)size -{ - CGRect rect = CGRectZero; - rect.size = [self sizeThatFits:size]; - return rect; -} - --(CGRect)estimateLayoutRect:(CGSize)size inSizeClass:(MySizeClass)sizeClass -{ - CGRect rect = CGRectZero; - rect.size = [self sizeThatFits:size inSizeClass:sizeClass]; - return rect; -} - - -#pragma mark -- Private Method +#pragma mark -- Private Methods diff --git a/MyLayout/Lib/MyBorderline.h b/MyLayout/Lib/MyBorderline.h index db04365..8266d50 100644 --- a/MyLayout/Lib/MyBorderline.h +++ b/MyLayout/Lib/MyBorderline.h @@ -58,7 +58,5 @@ @end -//兼容老版本的类名命名不规则的问题,这样老版本仍然可以用MyBorderLineDraw这个类名。 -typedef MyBorderline MyBorderLineDraw MYMETHODDEPRECATED("use MyBorderline to instead"); diff --git a/MyLayout/Lib/MyFloatLayout.h b/MyLayout/Lib/MyFloatLayout.h index ed9c3f4..9c5490a 100644 --- a/MyLayout/Lib/MyFloatLayout.h +++ b/MyLayout/Lib/MyFloatLayout.h @@ -140,12 +140,3 @@ @end - -@interface MyFloatLayout(MyFloatLayoutDeprecated) - --(void)setSubviewFloatMargin:(CGFloat)subviewSize minMargin:(CGFloat)minMargin MYMETHODDEPRECATED("use method: setSubviews:minSpace:maxSpace to replace"); --(void)setSubviewFloatMargin:(CGFloat)subviewSize minMargin:(CGFloat)minMargin inSizeClass:(MySizeClass)sizeClass MYMETHODDEPRECATED("use method: setSubviews:minSpace:maxSpace:inSizeClass to replace"); - - -@end - diff --git a/MyLayout/Lib/MyFloatLayout.m b/MyLayout/Lib/MyFloatLayout.m index d8bb479..a347c63 100644 --- a/MyLayout/Lib/MyFloatLayout.m +++ b/MyLayout/Lib/MyFloatLayout.m @@ -52,6 +52,8 @@ -(BOOL)clearFloat @implementation MyFloatLayout +#pragma mark -- Public Methods + -(instancetype)initWithFrame:(CGRect)frame orientation:(MyOrientation)orientation { self = [super initWithFrame:frame]; @@ -122,32 +124,7 @@ -(void)setSubviewsSize:(CGFloat)subviewSize minSpace:(CGFloat)minSpace maxSpace: } -#pragma mark -- Deprecated Method - - --(void)setSubviewFloatMargin:(CGFloat)subviewSize minMargin:(CGFloat)minMargin -{ - [self setSubviewsSize:subviewSize minSpace:minMargin maxSpace:CGFLOAT_MAX]; -} - --(void)setSubviewFloatMargin:(CGFloat)subviewSize minMargin:(CGFloat)minMargin inSizeClass:(MySizeClass)sizeClass -{ - [self setSubviewsSize:subviewSize minSpace:minMargin maxSpace:CGFLOAT_MAX inSizeClass:sizeClass]; -} - - - - -/* - // Only override drawRect: if you perform custom drawing. - // An empty implementation adversely affects performance during animation. - - (void)drawRect:(CGRect)rect { - // Drawing code - } - */ - - -#pragma mark -- Override Method +#pragma mark -- Override Methods -(CGSize)calcLayoutRect:(CGSize)size isEstimate:(BOOL)isEstimate pHasSubLayout:(BOOL*)pHasSubLayout sizeClass:(MySizeClass)sizeClass sbs:(NSMutableArray*)sbs { @@ -226,7 +203,7 @@ -(id)createSizeClassInstance return [MyFloatLayoutViewSizeClass new]; } -#pragma mark -- Private Method +#pragma mark -- Private Methods -(CGPoint)myFindTrailingCandidatePoint:(CGRect)leadingCandidateRect width:(CGFloat)width trailingBoundary:(CGFloat)trailingBoundary trailingCandidateRects:(NSArray*)trailingCandidateRects hasWeight:(BOOL)hasWeight paddingTop:(CGFloat)paddingTop { @@ -534,8 +511,13 @@ -(CGSize)myLayoutSubviewsForVert:(CGSize)selfSize sbs:(NSArray*)sbs isEstimate:( CGFloat maxHeight = paddingTop; CGFloat maxWidth = paddingLeading; - for (UIView *sbv in sbs) + //记录是否有子视图设置了对齐,如果设置了对齐就会在后面对每行子视图做对齐处理。 + BOOL sbvHasAlignment = NO; + NSMutableArray *lineIndexes = [NSMutableArray new]; + + for (NSInteger idx = 0; idx < sbs.count; idx++) { + UIView *sbv = sbs[idx]; MyFrame *sbvmyFrame = sbv.myFrame; UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame]; @@ -545,6 +527,9 @@ -(CGSize)myLayoutSubviewsForVert:(CGSize)selfSize sbs:(NSArray*)sbs isEstimate:( CGFloat trailingSpace = sbvsc.trailingPosInner.absVal; CGRect rect = sbvmyFrame.frame; + //只要有一个子视图设置了对齐,就会做对齐处理,否则不会,这里这样做是为了对后面的对齐计算做优化。 + sbvHasAlignment |= ((sbvsc.myAlignment & MyGravity_Horz_Mask) > MyGravity_Vert_Top); + if (subviewSize != 0) rect.size.width = subviewSize; @@ -723,6 +708,11 @@ -(CGSize)myLayoutSubviewsForVert:(CGSize)selfSize sbs:(NSArray*)sbs isEstimate:( } + //记录每一行的最大子视图位置的索引值。 + if (trailingLastYOffset != rect.origin.y - topSpace) + { + [lineIndexes addObject:@(idx - 1)]; + } [trailingCandidateRects addObject:[NSValue valueWithCGRect:cRect]]; trailingLastYOffset = rect.origin.y - topSpace; @@ -790,7 +780,7 @@ -(CGSize)myLayoutSubviewsForVert:(CGSize)selfSize sbs:(NSArray*)sbs isEstimate:( rect.origin.x = nextPoint.x + leadingSpace; rect.origin.y = _myCGFloatMin(nextPoint.y,maxHeight) + topSpace; - + if (!isEstimate && self.intelligentBorderline != nil) { //优先绘制左边和上边的。绘制左边的和上边的。 @@ -856,6 +846,11 @@ -(CGSize)myLayoutSubviewsForVert:(CGSize)selfSize sbs:(NSArray*)sbs isEstimate:( } } + //记录每一行的最大子视图位置的索引值。 + if (leadingLastYOffset != rect.origin.y - topSpace) + { + [lineIndexes addObject:@(idx - 1)]; + } [leadingCandidateRects addObject:[NSValue valueWithCGRect:cRect]]; leadingLastYOffset = rect.origin.y - topSpace; @@ -912,6 +907,64 @@ -(CGSize)myLayoutSubviewsForVert:(CGSize)selfSize sbs:(NSArray*)sbs isEstimate:( } } + + + //如果有子视图设置了对齐属性,那么就要对处在同一行内的子视图进行对齐设置。 + //对齐的规则是以行内最高的子视图作为参考的对象,其他的子视图按照行内最高子视图进行垂直对齐的调整。 + if (sbvHasAlignment) + { + //最后一行。 + if (sbs.count > 0) + { + [lineIndexes addObject:@(sbs.count - 1)]; + } + + NSInteger lineFirstIndex = 0; + for (NSNumber *idxnum in lineIndexes) + { + BOOL lineHasAlignment = NO; + + //计算每行内的最高的子视图,作为行对齐的标准。 + CGFloat lineMaxHeight = 0; + for (NSInteger i = lineFirstIndex; i <= idxnum.integerValue; i++) + { + UIView *sbv = sbs[i]; + MyFrame *sbvmyFrame = sbv.myFrame; + UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame]; + if (sbvmyFrame.height > lineMaxHeight) + lineMaxHeight = sbvmyFrame.height; + + lineHasAlignment |= ((sbvsc.myAlignment & MyGravity_Horz_Mask) > MyGravity_Vert_Top); + } + + //设置行内的对齐 + if (lineHasAlignment) + { + for (NSInteger i = lineFirstIndex; i <= idxnum.integerValue; i++) + { + UIView *sbv = sbs[i]; + MyFrame *sbvmyFrame = sbv.myFrame; + UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame]; + switch (sbvsc.myAlignment & MyGravity_Horz_Mask) { + case MyGravity_Vert_Center: + sbvmyFrame.top += (lineMaxHeight - sbvmyFrame.height) / 2.0; + break; + case MyGravity_Vert_Bottom: + sbvmyFrame.top += (lineMaxHeight - sbvmyFrame.height); + break; + case MyGravity_Vert_Fill: + sbvmyFrame.height = lineMaxHeight; + break; + default: + break; + } + } + } + + lineFirstIndex = idxnum.integerValue + 1; + } + } + return selfSize; } @@ -1037,8 +1090,13 @@ -(CGSize)myLayoutSubviewsForHorz:(CGSize)selfSize sbs:(NSArray*)sbs isEstimate:( CGFloat maxWidth = paddingLeading; CGFloat maxHeight = paddingTop; - for (UIView *sbv in sbs) + //记录是否有子视图设置了对齐,如果设置了对齐就会在后面对每行子视图做对齐处理。 + BOOL sbvHasAlignment = NO; + NSMutableArray *lineIndexes = [NSMutableArray new]; + + for (NSInteger idx = 0; idx < sbs.count; idx++) { + UIView *sbv = sbs[idx]; MyFrame *sbvmyFrame = sbv.myFrame; UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame]; @@ -1048,6 +1106,9 @@ -(CGSize)myLayoutSubviewsForHorz:(CGSize)selfSize sbs:(NSArray*)sbs isEstimate:( CGFloat trailingSpace = sbvsc.trailingPosInner.absVal; CGRect rect = sbvmyFrame.frame; + //只要有一个子视图设置了对齐,就会做对齐处理,否则不会,这里这样做是为了对后面的对齐计算做优化。 + sbvHasAlignment |= ((sbvsc.myAlignment & MyGravity_Vert_Mask) > MyGravity_Horz_Left); + if (sbvsc.widthSizeInner.dimeNumVal != nil) rect.size.width = sbvsc.widthSizeInner.measure; @@ -1219,6 +1280,12 @@ -(CGSize)myLayoutSubviewsForHorz:(CGSize)selfSize sbs:(NSArray*)sbs isEstimate:( } + //记录每一列的最大子视图位置的索引值。 + if (bottomLastXOffset != rect.origin.x - leadingSpace) + { + [lineIndexes addObject:@(idx - 1)]; + } + [bottomCandidateRects addObject:[NSValue valueWithCGRect:cRect]]; bottomLastXOffset = rect.origin.x - leadingSpace; @@ -1345,6 +1412,11 @@ -(CGSize)myLayoutSubviewsForHorz:(CGSize)selfSize sbs:(NSArray*)sbs isEstimate:( } + //记录每一列的最大子视图位置的索引值。 + if (topLastXOffset != rect.origin.x - leadingSpace) + { + [lineIndexes addObject:@(idx - 1)]; + } [topCandidateRects addObject:[NSValue valueWithCGRect:cRect]]; topLastXOffset = rect.origin.x - leadingSpace; @@ -1404,6 +1476,62 @@ -(CGSize)myLayoutSubviewsForHorz:(CGSize)selfSize sbs:(NSArray*)sbs isEstimate:( } + //如果有子视图设置了对齐属性,那么就要对处在同一列内的子视图进行对齐设置。 + //对齐的规则是以列内最宽的子视图作为参考的对象,其他的子视图按照列内最宽子视图进行水平对齐的调整。 + if (sbvHasAlignment) + { + //最后一列。 + if (sbs.count > 0) + { + [lineIndexes addObject:@(sbs.count - 1)]; + } + + NSInteger lineFirstIndex = 0; + for (NSNumber *idxnum in lineIndexes) + { + BOOL lineHasAlignment = NO; + + //计算每列内的最宽的子视图,作为列对齐的标准。 + CGFloat lineMaxWidth = 0; + for (NSInteger i = lineFirstIndex; i <= idxnum.integerValue; i++) + { + UIView *sbv = sbs[i]; + MyFrame *sbvmyFrame = sbv.myFrame; + UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame]; + if (sbvmyFrame.width > lineMaxWidth) + lineMaxWidth = sbvmyFrame.width; + + lineHasAlignment |= ((sbvsc.myAlignment & MyGravity_Vert_Mask) > MyGravity_Horz_Left); + } + + //设置行内的对齐 + if (lineHasAlignment) + { + for (NSInteger i = lineFirstIndex; i <= idxnum.integerValue; i++) + { + UIView *sbv = sbs[i]; + MyFrame *sbvmyFrame = sbv.myFrame; + UIView *sbvsc = [self myCurrentSizeClassFrom:sbvmyFrame]; + switch ([self myConvertLeftRightGravityToLeadingTrailing:sbvsc.myAlignment & MyGravity_Vert_Mask]) { + case MyGravity_Horz_Center: + sbvmyFrame.leading += (lineMaxWidth - sbvmyFrame.width) / 2.0; + break; + case MyGravity_Horz_Trailing: + sbvmyFrame.leading += (lineMaxWidth - sbvmyFrame.width); + break; + case MyGravity_Horz_Fill: + sbvmyFrame.width = lineMaxWidth; + break; + default: + break; + } + } + } + + lineFirstIndex = idxnum.integerValue + 1; + } + } + return selfSize; } diff --git a/MyLayout/Lib/MyFlowLayout.h b/MyLayout/Lib/MyFlowLayout.h index b647493..632ea3b 100644 --- a/MyLayout/Lib/MyFlowLayout.h +++ b/MyLayout/Lib/MyFlowLayout.h @@ -185,7 +185,7 @@ /** - *设置流式布局中每排内所有子视图的对齐停靠方式。具体的对齐停靠方式依赖于布局视图的方向: + 设置流式布局中每排内所有子视图的对齐停靠方式。具体的对齐停靠方式依赖于布局视图的方向: 1. 如果是垂直流式布局则表示每排内子视图的上中下对齐方式,这里的对齐基础是以每排中的最高的子视图为基准。这个属性只支持: @code @@ -229,18 +229,4 @@ @end -@interface MyFlowLayout(MyFlowLayoutDeprecated) - -/** - 指定是否均分布局方向上的子视图的宽度或者高度,或者拉伸子视图的尺寸,默认是NO。 - 如果是MyOrientation_Vert则表示每行的子视图的宽度会被均分,这样子视图不需要指定宽度,但是布局视图必须要指定一个明确的宽度值,如果设置为YES则wrapContentWidth会失效。 - 如果是MyOrientation_Horz则表示每列的子视图的高度会被均分,这样子视图不需要指定高度,但是布局视图必须要指定一个明确的高度值,如果设置为YES则wrapContentHeight会失效。 - 内容填充约束流式布局下averageArrange设置为YES时表示拉伸子视图的宽度或者高度以便填充满整个布局视图。 - */ -@property(nonatomic,assign) BOOL averageArrange MYMETHODDEPRECATED("use gravity = MyGravity_Horz_Fill or gravity = MyGravity_Vert_Fill to instead"); - - -@end - - diff --git a/MyLayout/Lib/MyFlowLayout.m b/MyLayout/Lib/MyFlowLayout.m index a299060..70db758 100644 --- a/MyLayout/Lib/MyFlowLayout.m +++ b/MyLayout/Lib/MyFlowLayout.m @@ -12,6 +12,7 @@ @implementation MyFlowLayout +#pragma mark -- Public Methods -(instancetype)initWithFrame:(CGRect)frame orientation:(MyOrientation)orientation arrangedCount:(NSInteger)arrangedCount { @@ -134,42 +135,8 @@ -(void)setSubviewsSize:(CGFloat)subviewSize minSpace:(CGFloat)minSpace maxSpace: [self setNeedsLayout]; } -#pragma mark -- Deprecated Method - --(void)setAverageArrange:(BOOL)averageArrange -{ - MyFlowLayout *lsc = self.myCurrentSizeClass; - - if (lsc.orientation == MyOrientation_Vert) - { - if (averageArrange) - lsc.gravity = (lsc.gravity & MyGravity_Horz_Mask) | MyGravity_Horz_Fill; - else - lsc.gravity = (lsc.gravity & MyGravity_Horz_Mask) | MyGravity_None; - } - else - { - if (averageArrange) - lsc.gravity = (lsc.gravity & MyGravity_Vert_Mask) | MyGravity_Vert_Fill; - else - lsc.gravity = (lsc.gravity & MyGravity_Vert_Mask) | MyGravity_None; - } - -} - --(BOOL)averageArrange -{ - MyFlowLayout *lsc = self.myCurrentSizeClass; - - if (lsc.orientation == MyOrientation_Vert) - return (lsc.gravity & MyGravity_Vert_Mask) == MyGravity_Horz_Fill; - else - return (lsc.gravity & MyGravity_Horz_Mask) == MyGravity_Vert_Fill; -} - - -#pragma mark -- Override Method +#pragma mark -- Override Methods -(CGSize)calcLayoutRect:(CGSize)size isEstimate:(BOOL)isEstimate pHasSubLayout:(BOOL*)pHasSubLayout sizeClass:(MySizeClass)sizeClass sbs:(NSMutableArray*)sbs { @@ -266,7 +233,7 @@ -(id)createSizeClassInstance return [MyFlowLayoutViewSizeClass new]; } -#pragma mark -- Private Method +#pragma mark -- Private Methods - (void)myCalcVertLayoutSinglelineWeight:(CGSize)selfSize totalFloatWidth:(CGFloat)totalFloatWidth totalWeight:(CGFloat)totalWeight sbs:(NSArray *)sbs startIndex:(NSInteger)startIndex count:(NSInteger)count diff --git a/MyLayout/Lib/MyFrameLayout.h b/MyLayout/Lib/MyFrameLayout.h index fb35c7c..5ebb3c9 100644 --- a/MyLayout/Lib/MyFrameLayout.h +++ b/MyLayout/Lib/MyFrameLayout.h @@ -8,26 +8,6 @@ #import "MyBaseLayout.h" -/* -@interface UIView(MyFrameLayoutExt) - -//新版本1.3.3以后的版本将不再提供框架布局对子视图的这个扩展属性的支持。 -@property(nonatomic, assign) MyGravity marginGravity; - - 1.如果您想让子视图右对齐框架布局,则只需要设置myRight = 数值 和宽度即可 不再需要设置marginGravity = MyGravity_Horz_Right - 2.如果您想让子视图底对齐框架布局,则只需要设置myBottom = 数值 和高度即可,不再需要设置marginGravity = MyGravity_Vert_Bottom - 3.如果您想让子视图在框架布局中垂直居中,则只需要设置myCenterY = 数值 和高度即可,不再需要设置marginGravity = MyGravity_Vert_Center - 4.如果您想让子视图在框架布局中水平居中,则只需要设置myCenterX = 数值 和宽度即可,不再需要设置marginGravity = MyGravity_Horz_Center - 5.如果您想让子视图在框架布局中宽度填满,则只需要设置myHorzMargin = 0,不再需要设置marginGravity = MyGravity_Horz_Fill - 6.如果您想让子视图在框架布局中高度填满,则只需要设置myVertMargin = 0, 不再需要设置marginGravity = MyGravity_Vert_Fill - 7.如果你要水平和垂直方向都设置,则请同时设置对应位置对象的值。 - 8.新版本将不再支持让框架布局中的子视图在窗口中居中了。 - - - 请使用了marginGravity属性的代码进行对应的代码变更!!! - -@end -*/ /** 框架布局是一种里面的子视图停靠在父视图特定方位并且可以重叠的布局视图。框架布局里面的子视图的布局位置和添加的顺序无关,框架布局中的所有子视图的约束依赖都只是针对于和父布局视图的。框架布局是一种特殊的相对布局,因此如果某些布局里面的子视图只依赖于父视图的边界时则可以用框架布局来代替,从而加快布局的速度。 diff --git a/MyLayout/Lib/MyFrameLayout.m b/MyLayout/Lib/MyFrameLayout.m index eb354eb..6d70d10 100644 --- a/MyLayout/Lib/MyFrameLayout.m +++ b/MyLayout/Lib/MyFrameLayout.m @@ -22,7 +22,7 @@ - (void)drawRect:(CGRect)rect { */ -#pragma mark -- Override Method +#pragma mark -- Override Methods -(CGSize)calcLayoutRect:(CGSize)size isEstimate:(BOOL)isEstimate pHasSubLayout:(BOOL*)pHasSubLayout sizeClass:(MySizeClass)sizeClass sbs:(NSMutableArray *)sbs @@ -111,6 +111,7 @@ -(id)createSizeClassInstance } +#pragma mark -- Private Methods -(void)myCalcSubViewRect:(UIView*)sbv diff --git a/MyLayout/Lib/MyGrid.h b/MyLayout/Lib/MyGrid.h index a3c4227..f164c53 100644 --- a/MyLayout/Lib/MyGrid.h +++ b/MyLayout/Lib/MyGrid.h @@ -102,11 +102,15 @@ extern NSString * const vMyGridGravityHeightFill; //对应MyGravity_Vert_Fill @property(nonatomic, weak, readonly) id superGrid; -//得到所有子栅格 +/** + 得到所有子栅格 + */ @property(nonatomic, strong, readonly) NSArray> *subGrids; -//克隆出一个新栅格以及其下的所有子栅格。 +/** + 克隆出一个新栅格以及其下的所有子栅格。 + */ -(id)cloneGrid; diff --git a/MyLayout/Lib/MyGridLayout.m b/MyLayout/Lib/MyGridLayout.m index fa76ded..16ad83a 100644 --- a/MyLayout/Lib/MyGridLayout.m +++ b/MyLayout/Lib/MyGridLayout.m @@ -109,7 +109,7 @@ -(NSMutableDictionary*)tagsDict return _tagsDict; } -#pragma mark -- Public Method +#pragma mark -- Public Methods +(id)createTemplateGrid:(NSInteger)gridTag { @@ -776,7 +776,7 @@ - (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event -#pragma mark -- Override Method +#pragma mark -- Override Methods -(void)dealloc { @@ -929,7 +929,7 @@ -(id)createSizeClassInstance return [MyGridLayoutViewSizeClass new]; } -#pragma mark -- Private Method +#pragma mark -- Private Methods //遍历位置 -(void)myTraversalGridOrigin:(id)grid gridOrigin:(CGPoint)gridOrigin lsc:(MyGridLayout*)lsc sbvEnumerator:(NSEnumerator*)sbvEnumerator tagViewGroupIndexDict:(NSMutableDictionary*)tagViewGroupIndexDict tagSbvEnumerator:(NSEnumerator*)tagSbvEnumerator isEstimate:(BOOL)isEstimate sizeClass:(MySizeClass)sizeClass pHasSubLayout:(BOOL*)pHasSubLayout diff --git a/MyLayout/Lib/MyLayout.h b/MyLayout/Lib/MyLayout.h index 9269636..ea5ddba 100644 --- a/MyLayout/Lib/MyLayout.h +++ b/MyLayout/Lib/MyLayout.h @@ -37,7 +37,7 @@ */ -//Current version is 1.5.0, please open: https://github.com/youngsoft/MyLinearLayout/blob/master/CHANGELOG.md to show the changes. +//Current version is 1.5.1, please open: https://github.com/youngsoft/MyLinearLayout/blob/master/CHANGELOG.md to show the changes. #ifndef MyLayout_MyLayout_h diff --git a/MyLayout/Lib/MyLayoutDef.h b/MyLayout/Lib/MyLayoutDef.h index 30d3e2d..0de4f02 100644 --- a/MyLayout/Lib/MyLayoutDef.h +++ b/MyLayout/Lib/MyLayoutDef.h @@ -32,28 +32,24 @@ *布局视图方向的枚举类型定义。用来指定布局内子视图的整体排列布局方向。 */ typedef enum : unsigned char { - MyOrientation_Vert = 0, /**垂直方向,布局视图内所有子视图整体从上到下排列布局*/ - MyOrientation_Horz = 1, /**水平方向,布局视图内所有子视图整体从左到右排列布局*/ - - - //兼容老版本而定义,请使用新的定义值。 - MyLayoutViewOrientation_Vert MYMETHODDEPRECATED("use MyOrientation_Vert to instead") = MyOrientation_Vert, - MyLayoutViewOrientation_Horz MYMETHODDEPRECATED("use MyOrientation_Horz to instead") = MyOrientation_Horz, - + /**垂直方向,布局视图内所有子视图整体从上到下排列布局*/ + MyOrientation_Vert = 0, + /**水平方向,布局视图内所有子视图整体从左到右排列布局*/ + MyOrientation_Horz = 1, } MyOrientation; -//为了兼容老版本而定义 -typedef MyOrientation MyLayoutViewOrientation MYMETHODDEPRECATED("use MyOrientation to instead"); - /** *视图的可见性枚举类型定义。用来指定视图是否在布局中可见,他是对hidden属性的扩展设置。 */ typedef enum : unsigned char { - MyVisibility_Visible, /**视图可见,等价于hidden = false*/ - MyVisibility_Invisible, /**视图隐藏,等价于hidden = true, 但是会在父布局视图中占位空白区域*/ - MyVisibility_Gone /**视图隐藏,等价于hidden = true, 但是不会在父视图中占位空白区域*/ + /**视图可见,等价于hidden = false*/ + MyVisibility_Visible, + /**视图隐藏,等价于hidden = true, 但是会在父布局视图中占位空白区域*/ + MyVisibility_Invisible, + /**视图隐藏,等价于hidden = true, 但是不会在父视图中占位空白区域*/ + MyVisibility_Gone }MyVisibility; @@ -69,66 +65,59 @@ typedef enum : unsigned short { - - MyGravity_None = 0, /**默认值,不停靠、不填充、不对齐。*/ + /**默认值,不停靠、不填充、不对齐。*/ + MyGravity_None = 0, //水平方向 - MyGravity_Horz_Left = 1, /**左边停靠或者左对齐*/ - MyGravity_Horz_Center = 2, /**水平中心停靠或者水平居中对齐*/ - MyGravity_Horz_Right = 4, /**右边停靠或者右对齐*/ - MyGravity_Horz_Window_Center = 8, /**窗口水平中心停靠,表示在屏幕窗口的水平中心停靠*/ - MyGravity_Horz_Between = 16, /**水平间距拉伸*/ - MyGravity_Horz_Leading = 32, /**头部对齐,对于阿拉伯国家来说是和Right等价的,对于非阿拉伯国家则是和Left等价的*/ - MyGravity_Horz_Trailing = 64, /**尾部对齐,对于阿拉伯国家来说是和Left等价的,对于非阿拉伯国家则是和Right等价的*/ - MyGravity_Horz_Fill = MyGravity_Horz_Left | MyGravity_Horz_Center | MyGravity_Horz_Right, /**水平宽度填充*/ - MyGravity_Horz_Mask = 0xFF00, /**水平掩码,用来获取水平方向的枚举值*/ + /**左边停靠或者左对齐*/ + MyGravity_Horz_Left = 1, + /**水平中心停靠或者水平居中对齐*/ + MyGravity_Horz_Center = 2, + /**右边停靠或者右对齐*/ + MyGravity_Horz_Right = 4, + /**窗口水平中心停靠,表示在屏幕窗口的水平中心停靠*/ + MyGravity_Horz_Window_Center = 8, + /**水平间距拉伸*/ + MyGravity_Horz_Between = 16, + /**头部对齐,对于阿拉伯国家来说是和Right等价的,对于非阿拉伯国家则是和Left等价的*/ + MyGravity_Horz_Leading = 32, + /**尾部对齐,对于阿拉伯国家来说是和Left等价的,对于非阿拉伯国家则是和Right等价的*/ + MyGravity_Horz_Trailing = 64, + /**水平宽度填充*/ + MyGravity_Horz_Fill = MyGravity_Horz_Left | MyGravity_Horz_Center | MyGravity_Horz_Right, + /**水平掩码,用来获取水平方向的枚举值*/ + MyGravity_Horz_Mask = 0xFF00, //垂直方向 - MyGravity_Vert_Top = 1 << 8, /**上边停靠或者上对齐*/ - MyGravity_Vert_Center = 2 << 8, /**垂直中心停靠或者垂直居中对齐*/ - MyGravity_Vert_Bottom = 4 << 8, /**下边停靠或者下边对齐*/ - MyGravity_Vert_Window_Center = 8 << 8, /**窗口垂直中心停靠,表示在屏幕窗口的垂直中心停靠*/ - MyGravity_Vert_Between = 16 << 8, /**垂直间距拉伸*/ - MyGravity_Vert_Baseline = 32 << 8, /**基线对齐,只支持水平线性布局,指定基线对齐必须要指定出一个基线标准的子视图*/ - MyGravity_Vert_Fill = MyGravity_Vert_Top | MyGravity_Vert_Center | MyGravity_Vert_Bottom, /**垂直高度填充*/ - MyGravity_Vert_Mask = 0x00FF, /**垂直掩码,用来获取垂直方向的枚举值*/ - - - MyGravity_Center = MyGravity_Horz_Center | MyGravity_Vert_Center, /**整体居中*/ - - - MyGravity_Fill = MyGravity_Horz_Fill | MyGravity_Vert_Fill, /**全部填充*/ - - - MyGravity_Between = MyGravity_Horz_Between | MyGravity_Vert_Between, /**全部拉伸*/ - - - //为了更正确的统一命名规范以及和TangramKit保持一致,下列属性定义设置为过期!!。您在更新版本后只需要统一将MyMarginGravity替换为MyGravity 即可 - MyMarginGravity_None MYMETHODDEPRECATED("use MyGravity_None to instead") = MyGravity_None, - MyMarginGravity_Horz_Left MYMETHODDEPRECATED("use MyGravity_Horz_Left to instead") = MyGravity_Horz_Left, - MyMarginGravity_Horz_Center MYMETHODDEPRECATED("use MyGravity_Horz_Center to instead") = MyGravity_Horz_Center, - MyMarginGravity_Horz_Right MYMETHODDEPRECATED("use MyGravity_Horz_Right to instead") = MyGravity_Horz_Right, - MyMarginGravity_Horz_Window_Center MYMETHODDEPRECATED("use MyGravity_Horz_Window_Center to instead") = MyGravity_Horz_Window_Center, - MyMarginGravity_Horz_Between MYMETHODDEPRECATED("use MyGravity_Horz_Between to instead") = MyGravity_Horz_Between, - MyMarginGravity_Horz_Fill MYMETHODDEPRECATED("use MyGravity_Horz_Fill to instead") = MyGravity_Horz_Fill, - MyMarginGravity_Horz_Mask MYMETHODDEPRECATED("use MyGravity_Horz_Mask to instead") = MyGravity_Horz_Mask, - MyMarginGravity_Vert_Top MYMETHODDEPRECATED("use MyGravity_Vert_Top to instead") = MyGravity_Vert_Top, - MyMarginGravity_Vert_Center MYMETHODDEPRECATED("use MyGravity_Vert_Center to instead") = MyGravity_Vert_Center, - MyMarginGravity_Vert_Bottom MYMETHODDEPRECATED("use MyGravity_Vert_Bottom to instead") = MyGravity_Vert_Bottom, - MyMarginGravity_Vert_Window_Center MYMETHODDEPRECATED("use MyGravity_Vert_Window_Center to instead") = MyGravity_Vert_Window_Center, - MyMarginGravity_Vert_Between MYMETHODDEPRECATED("use MyGravity_Vert_Between to instead") = MyGravity_Vert_Between, - MyMarginGravity_Vert_Fill MYMETHODDEPRECATED("use MyGravity_Vert_Fill to instead") = MyGravity_Vert_Fill, - MyMarginGravity_Vert_Mask MYMETHODDEPRECATED("use MyGravity_Vert_Mask to instead") = MyGravity_Vert_Mask, - MyMarginGravity_Center MYMETHODDEPRECATED("use MyGravity_Center to instead") = MyGravity_Center, - MyMarginGravity_Fill MYMETHODDEPRECATED("use MyGravity_Fill to instead") = MyGravity_Fill, - MyMarginGravity_Between MYMETHODDEPRECATED("use MyGravity_Between to instead") = MyGravity_Between + /**上边停靠或者上对齐*/ + MyGravity_Vert_Top = 1 << 8, + /**垂直中心停靠或者垂直居中对齐*/ + MyGravity_Vert_Center = 2 << 8, + /**下边停靠或者下边对齐*/ + MyGravity_Vert_Bottom = 4 << 8, + /**窗口垂直中心停靠,表示在屏幕窗口的垂直中心停靠*/ + MyGravity_Vert_Window_Center = 8 << 8, + /**垂直间距拉伸*/ + MyGravity_Vert_Between = 16 << 8, + /**基线对齐,只支持水平线性布局,指定基线对齐必须要指定出一个基线标准的子视图*/ + MyGravity_Vert_Baseline = 32 << 8, + /**垂直高度填充*/ + MyGravity_Vert_Fill = MyGravity_Vert_Top | MyGravity_Vert_Center | MyGravity_Vert_Bottom, + /**垂直掩码,用来获取垂直方向的枚举值*/ + MyGravity_Vert_Mask = 0x00FF, + + /**整体居中*/ + MyGravity_Center = MyGravity_Horz_Center | MyGravity_Vert_Center, + + /**全部填充*/ + MyGravity_Fill = MyGravity_Horz_Fill | MyGravity_Vert_Fill, + + /**全部拉伸*/ + MyGravity_Between = MyGravity_Horz_Between | MyGravity_Vert_Between, } MyGravity; -//为了兼容老版本出现告警而定义。 -typedef MyGravity MyMarginGravity MYMETHODDEPRECATED("use MyGravity to instead"); - /** *设置当将布局视图嵌入到UIScrollView以及其派生类时对UIScrollView的contentSize的调整设置模式的枚举类型定义。 @@ -136,34 +125,37 @@ typedef MyGravity MyMarginGravity MYMETHODDEPRECATED("use MyGravity to instead") */ typedef enum :unsigned char { - MyAdjustScrollViewContentSizeModeAuto = 0, /**自动调整,在添加到UIScrollView之前(UITableView, UICollectionView除外)。如果值被设置Auto则在添加到父视图后自动会变为YES。*/ - MyAdjustScrollViewContentSizeModeNo = 1, /**不调整,任何加入到UIScrollView中的布局视图在尺寸变化时都不会调整和设置contentSize的值。*/ - MyAdjustScrollViewContentSizeModeYes = 2, /**会调整,任何加入到UIScrollView中的布局视图在尺寸变化时都会调整和设置contentSize的值。*/ - - - //下面为兼容老版本而定义,请使用新属性 - MyLayoutAdjustScrollViewContentSizeModeAuto MYMETHODDEPRECATED("use MyAdjustScrollViewContentSizeModeAuto to instead") = MyAdjustScrollViewContentSizeModeAuto, - MyLayoutAdjustScrollViewContentSizeModeNo MYMETHODDEPRECATED("use MyAdjustScrollViewContentSizeModeNo to instead") = MyAdjustScrollViewContentSizeModeNo, - MyLayoutAdjustScrollViewContentSizeModeYes MYMETHODDEPRECATED("use MyAdjustScrollViewContentSizeModeYes to instead") = MyAdjustScrollViewContentSizeModeYes, + /**自动调整,在添加到UIScrollView之前(UITableView, UICollectionView除外)。如果值被设置Auto则在添加到父视图后自动会变为YES。*/ + MyAdjustScrollViewContentSizeModeAuto = 0, + /**不调整,任何加入到UIScrollView中的布局视图在尺寸变化时都不会调整和设置contentSize的值。*/ + MyAdjustScrollViewContentSizeModeNo = 1, + /**会调整,任何加入到UIScrollView中的布局视图在尺寸变化时都会调整和设置contentSize的值。*/ + MyAdjustScrollViewContentSizeModeYes = 2, }MyAdjustScrollViewContentSizeMode; -//为兼容老版本而定义 -typedef MyAdjustScrollViewContentSizeMode MyLayoutAdjustScrollViewContentSizeMode MYMETHODDEPRECATED("use MyAdjustScrollViewContentSizeMode to instead"); /** *用来设置当线性布局中的子视图的尺寸大于线性布局的尺寸时的子视图的压缩策略和压缩内容枚举类型定义。请参考线性布局的shrinkType属性的定义。 */ typedef enum : NSUInteger { - MySubviewsShrink_None = 0, /**不压缩。*/ - MySubviewsShrink_Average = 1, /**平均压缩。*/ - MySubviewsShrink_Weight = 2, /**比例压缩。*/ - MySubviewsShrink_Auto = 4, /**自动压缩。这个属性只有在水平线性布局里面并且只有2个子视图的宽度等于自身时才有用。这个属性主要用来实现左右两个子视图根据自身内容来进行缩放,以便实现最佳的宽度空间利用。*/ + /**不压缩。*/ + MySubviewsShrink_None = 0, + /**平均压缩。*/ + MySubviewsShrink_Average = 1, + /**比例压缩。*/ + MySubviewsShrink_Weight = 2, + /**自动压缩。这个属性只有在水平线性布局里面并且只有2个子视图的宽度等于自身时才有用。这个属性主要用来实现左右两个子视图根据自身内容来进行缩放,以便实现最佳的宽度空间利用。*/ + MySubviewsShrink_Auto = 4, //上面部分是压缩的策略,下面部分指定压缩的内容,因此一个shrinkType的指定时上面部分和下面部分的 | 操作。比如让间距平均压缩:MySubviewsShrink_Average | MySubviewsShrink_Space - MySubviewsShrink_Size = 0 << 4, /**只压缩尺寸,因为这里是0所以这部分可以不设置,为默认。*/ - MySubviewsShrink_Space = 1 << 4, /**只压缩间距。*/ - MySubviewsShrink_SizeAndSpace = 2 << 4 /**压缩尺寸和间距。暂时不支持!!!*/ + + /**只压缩尺寸,因为这里是0所以这部分可以不设置,为默认。*/ + MySubviewsShrink_Size = 0 << 4, + /**只压缩间距。*/ + MySubviewsShrink_Space = 1 << 4, + /**压缩尺寸和间距。暂时不支持!!!*/ + MySubviewsShrink_SizeAndSpace = 2 << 4 } MySubviewsShrinkType; diff --git a/MyLayout/Lib/MyLayoutInner.h b/MyLayout/Lib/MyLayoutInner.h index 693c116..c2f2728 100644 --- a/MyLayout/Lib/MyLayoutInner.h +++ b/MyLayout/Lib/MyLayoutInner.h @@ -148,12 +148,8 @@ @property(nonatomic, strong,readonly) MyLayoutPos *baselinePosInner; -#if UIKIT_DEFINE_AS_PROPERTIES @property(class, nonatomic, assign) BOOL isRTL; -#else -+(BOOL)isRTL; -+(void)setIsRTL:(BOOL)isRTL; -#endif + @end diff --git a/MyLayout/Lib/MyLayoutMath.m b/MyLayout/Lib/MyLayoutMath.m index fd2b501..c724861 100644 --- a/MyLayout/Lib/MyLayoutMath.m +++ b/MyLayout/Lib/MyLayoutMath.m @@ -112,8 +112,7 @@ CGFloat _myCGFloatRound(CGFloat f) if (scale == 0) scale = [UIScreen mainScreen].scale; - //因为设备点转化为像素时,如果偏移了半个像素点就有可能会产生虚化的效果,因此这里要加上1/4个点的偏移来防止这种虚化现象的产生。 - // floor((f + 0.5 / scale )* scale) 的目的是将设备逻辑点转化为有效的像素。再除以倍数则是转化为有效的设备逻辑点。 + //因为设备点转化为像素时,如果偏移了半个像素点就有可能会产生虚化的效果,因此这里要将设备点先转化为像素点,然后再添加0.5个偏移取整后再除以倍数则是转化为有效的设备逻辑点。 #if CGFLOAT_IS_DOUBLE == 1 if (f < 0) return ceil(fma(f, scale, -0.5)) / scale; diff --git a/MyLayout/Lib/MyLayoutPos.h b/MyLayout/Lib/MyLayoutPos.h index 133ca26..7bdf5c3 100644 --- a/MyLayout/Lib/MyLayoutPos.h +++ b/MyLayout/Lib/MyLayoutPos.h @@ -75,8 +75,6 @@ */ @interface MyLayoutPos : NSObject -#if UIKIT_DEFINE_AS_PROPERTIES - /** 特殊的位置。只用在布局视图和非布局父视图之间的位置约束和没有导航条时的布局视图内子视图的padding设置上。 iOS11以后提出了安全区域的概念,因此对于iOS11以下的版本就需要兼容处理,尤其是在那些没有导航条的情况下。通过将布局视图的边距设置为这个特殊值就可以实现在任何版本中都能完美的实现位置的偏移而且各版本保持统一。比如下面的例子: @@ -113,10 +111,6 @@ */ @property(class, nonatomic, assign,readonly) CGFloat safeAreaMargin; -#else - -+(CGFloat)safeAreaMargin; -#endif //because masonry defined macro MAS_SHORTHAND_GLOBALS. the equalTo, offset may conflict with below method. so //if you used MyLayout and Masonry concurrently and you defined MAS_SHORTHAND_GLOBALS in masonry, then you can define MY_USEPREFIXMETHOD to solve the conflict. diff --git a/MyLayout/Lib/MyLayoutPos.m b/MyLayout/Lib/MyLayoutPos.m index 9f21eef..ff615a3 100644 --- a/MyLayout/Lib/MyLayoutPos.m +++ b/MyLayout/Lib/MyLayoutPos.m @@ -230,7 +230,7 @@ -(id)copyWithZone:(NSZone *)zone } -#pragma mark -- Private Method +#pragma mark -- Private Methods -(NSNumber*)posNumVal diff --git a/MyLayout/Lib/MyLayoutSize.h b/MyLayout/Lib/MyLayoutSize.h index ce13987..590d0d5 100644 --- a/MyLayout/Lib/MyLayoutSize.h +++ b/MyLayout/Lib/MyLayoutSize.h @@ -24,7 +24,6 @@ */ @interface MyLayoutSize : NSObject -#if UIKIT_DEFINE_AS_PROPERTIES /**特殊的尺寸,表示尺寸由子视图决定或者由内容决定。目前只用在表格布局MyTableLayout和栅格布局MyGridLayout中。*/ @property(class, nonatomic, assign,readonly) CGFloat wrap; @@ -33,13 +32,6 @@ /**特殊的尺寸,表示尺寸会均分父视图的剩余空间。目前只用在表格布局MyTableLayout */ @property(class, nonatomic, assign,readonly) CGFloat average; -#else - -+(CGFloat)wrap; -+(CGFloat)fill; -+(CGFloat)average; - -#endif //because masonry defined macro MAS_SHORTHAND_GLOBALS. the equalTo, offset may conflict with below method. so //if you used MyLayout and Masonry concurrently and you defined MAS_SHORTHAND_GLOBALS in masonry, then you can define MY_USEPREFIXMETHOD to solve the conflict. diff --git a/MyLayout/Lib/MyLayoutSize.m b/MyLayout/Lib/MyLayoutSize.m index 3189c57..47aebec 100644 --- a/MyLayout/Lib/MyLayoutSize.m +++ b/MyLayout/Lib/MyLayoutSize.m @@ -261,7 +261,7 @@ -(id)copyWithZone:(NSZone *)zone return self; } -#pragma mark -- Private Method +#pragma mark -- Private Methods -(NSNumber*)dimeNumVal @@ -546,7 +546,7 @@ +(NSString*)dimestrFromDime:(MyLayoutSize*)dimeobj showView:(BOOL)showView } -#pragma mark -- Override Method +#pragma mark -- Override Methods -(NSString*)description { diff --git a/MyLayout/Lib/MyLinearLayout.h b/MyLayout/Lib/MyLinearLayout.h index acf4db1..9ca73f5 100644 --- a/MyLayout/Lib/MyLinearLayout.h +++ b/MyLayout/Lib/MyLinearLayout.h @@ -195,21 +195,4 @@ @end -@interface MyLinearLayout(MyLinearLayoutDeprecated) - -/** - * 过期的方法,这些过期的方法名取名不规范,因此为了和TangramKit统一,这里将这些不规范的方法设置为过期。 - */ --(void)averageSubviews:(BOOL)centered MYMETHODDEPRECATED("use ’equalizeSubviews:(BOOL)centered‘ to instead"); --(void)averageSubviews:(BOOL)centered inSizeClass:(MySizeClass)sizeClass MYMETHODDEPRECATED("use ‘equalizeSubviews:(BOOL)centered inSizeClass:(MySizeClass)sizeClass’ to instead"); - --(void)averageSubviews:(BOOL)centered withMargin:(CGFloat)margin MYMETHODDEPRECATED("use ‘equalizeSubviews:(BOOL)centered withSpace:(CGFloat)space’ to instead"); --(void)averageSubviews:(BOOL)centered withMargin:(CGFloat)margin inSizeClass:(MySizeClass)sizeClass MYMETHODDEPRECATED("use ‘equalizeSubviews:(BOOL)centered withSpace:(CGFloat)space inSizeClass:(MySizeClass)sizeClass’ to instead"); - --(void)averageMargin:(BOOL)centered MYMETHODDEPRECATED("use ‘equalizeSubviewsSpace:(BOOL)centered’ to instead"); --(void)averageMargin:(BOOL)centered inSizeClass:(MySizeClass)sizeClass MYMETHODDEPRECATED("use ‘equalizeSubviewsSpace:(BOOL)centered inSizeClass:(MySizeClass)sizeClass’ to instead"); - - -@end - diff --git a/MyLayout/Lib/MyLinearLayout.m b/MyLayout/Lib/MyLinearLayout.m index 3f96915..9577ee0 100644 --- a/MyLayout/Lib/MyLinearLayout.m +++ b/MyLayout/Lib/MyLinearLayout.m @@ -11,6 +11,8 @@ @implementation MyLinearLayout +#pragma mark -- Public Methods + -(instancetype)initWithFrame:(CGRect)frame orientation:(MyOrientation)orientation { self = [super initWithFrame:frame]; @@ -138,43 +140,7 @@ -(void)equalizeSubviewsSpace:(BOOL)centered inSizeClass:(MySizeClass)sizeClass } -#pragma mark -- Deprecated Method - --(void)averageSubviews:(BOOL)centered -{ - [self equalizeSubviews:centered]; -} - --(void)averageSubviews:(BOOL)centered inSizeClass:(MySizeClass)sizeClass -{ - [self equalizeSubviews:centered inSizeClass:sizeClass]; -} - - --(void)averageSubviews:(BOOL)centered withMargin:(CGFloat)margin -{ - [self equalizeSubviews:centered withSpace:margin]; -} - --(void)averageSubviews:(BOOL)centered withMargin:(CGFloat)margin inSizeClass:(MySizeClass)sizeClass -{ - [self equalizeSubviews:centered withSpace:margin inSizeClass:sizeClass]; -} - - - --(void)averageMargin:(BOOL)centered -{ - [self equalizeSubviewsSpace:centered]; -} - --(void)averageMargin:(BOOL)centered inSizeClass:(MySizeClass)sizeClass -{ - [self equalizeSubviewsSpace:centered inSizeClass:sizeClass]; -} - - -#pragma mark -- Override Method +#pragma mark -- Override Methods - (void)willMoveToSuperview:(UIView*)newSuperview { @@ -295,7 +261,7 @@ -(id)createSizeClassInstance } -#pragma mark -- Private Method +#pragma mark -- Private Methods //调整子视图的wrapContent设置 - (void)myAdjustSubviewWrapContent:(UIView*)sbv sbvsc:(UIView*)sbvsc orientation:(MyOrientation)orientation gravity:(MyGravity)gravity diff --git a/MyLayout/Lib/MyPathLayout.m b/MyLayout/Lib/MyPathLayout.m index 57963a2..6916d0e 100644 --- a/MyLayout/Lib/MyPathLayout.m +++ b/MyLayout/Lib/MyPathLayout.m @@ -140,11 +140,13 @@ @interface MyPathLayout() @implementation MyPathLayout { - MyCoordinateSetting *_coordinateSetting; BOOL _hasOriginView; + MyCoordinateSetting *_coordinateSetting; MyPathSpace *_spaceType; } +#pragma mark -- Public Methods + /* +(Class)layerClass { @@ -402,7 +404,7 @@ -(CGPathRef)createPath:(NSInteger)subviewCount } -#pragma mark -- Override Method +#pragma mark -- Override Methods - (void)insertSubview:(UIView *)view atIndex:(NSInteger)index { @@ -807,7 +809,7 @@ -(id)createSizeClassInstance -#pragma mark -- Private Method +#pragma mark -- Private Methods -(CGFloat)myCalcDistance:(CGPoint)pt1 with:(CGPoint)pt2 diff --git a/MyLayout/Lib/MyRelativeLayout.h b/MyLayout/Lib/MyRelativeLayout.h index 5457a82..7122321 100644 --- a/MyLayout/Lib/MyRelativeLayout.h +++ b/MyLayout/Lib/MyRelativeLayout.h @@ -17,17 +17,4 @@ */ @interface MyRelativeLayout : MyBaseLayout - -/** - *这个属性已经无效了,请使用子视图自身的扩展属性myVisibility属性来进行子视图的隐藏和显示的定制化处理。 - */ -@property(nonatomic, assign) BOOL flexOtherViewWidthWhenSubviewHidden MYMETHODDEPRECATED("this property was invalid, please use subview's myVisibility to instead"); - -/** - *这个属性已经无效了,请使用子视图自身的扩展属性myVisibility属性来进行子视图的隐藏和显示的定制化处理。 - */ -@property(nonatomic, assign) BOOL flexOtherViewHeightWhenSubviewHidden MYMETHODDEPRECATED("this property was invalid, please use subview's myVisibility to instead"); -; - - @end diff --git a/MyLayout/Lib/MyRelativeLayout.m b/MyLayout/Lib/MyRelativeLayout.m index 47032dd..4507a92 100644 --- a/MyLayout/Lib/MyRelativeLayout.m +++ b/MyLayout/Lib/MyRelativeLayout.m @@ -12,36 +12,8 @@ @implementation MyRelativeLayout -/* - // Only override drawRect: if you perform custom drawing. - // An empty implementation adversely affects performance during animation. - - (void)drawRect:(CGRect)rect { - // Drawing code - } - */ - --(void)setFlexOtherViewWidthWhenSubviewHidden:(BOOL)flexOtherViewWidthWhenSubviewHidden -{ - NSAssert(0, @"oops!, flexOtherViewWidthWhenSubviewHidden is invalid please use subview's myVisibility to instead!!!"); -} - --(BOOL)flexOtherViewWidthWhenSubviewHidden -{ - return NO; -} - --(void)setFlexOtherViewHeightWhenSubviewHidden:(BOOL)flexOtherViewHeightWhenSubviewHidden -{ - NSAssert(0, @"oops!, flexOtherViewHeightWhenSubviewHidden is invalid please use subview's myVisibility to instead!!!"); -} - --(BOOL)flexOtherViewHeightWhenSubviewHidden -{ - return NO; -} - -#pragma mark -- Override Method +#pragma mark -- Override Methods -(CGSize)calcLayoutRect:(CGSize)size isEstimate:(BOOL)isEstimate pHasSubLayout:(BOOL*)pHasSubLayout sizeClass:(MySizeClass)sizeClass sbs:(NSMutableArray*)sbs { diff --git a/MyLayout/Lib/MyTableLayout.h b/MyLayout/Lib/MyTableLayout.h index 1b743af..8a73cc6 100644 --- a/MyLayout/Lib/MyTableLayout.h +++ b/MyLayout/Lib/MyTableLayout.h @@ -8,12 +8,6 @@ #import "MyLinearLayout.h" -//定义特殊的行列尺寸。主要用于表格布局中。请不要再使用如下的宏,而是改用MyLayoutSize中对应的类属性来代替。 -#define MTLSIZE_AVERAGE MyLayoutSize.average -#define MTLSIZE_WRAPCONTENT MyLayoutSize.wrap -#define MTLSIZE_MATCHPARENT MyLayoutSize.fill - - /** 表格布局行列索引描述扩展对象。 @@ -102,7 +96,7 @@ /** - * 删除一行 + *删除一行 */ -(void)removeRowAt:(NSInteger)rowIndex; @@ -170,15 +164,4 @@ @end -@interface MyTableLayout(MyTableDeprecated) - - -/** - * 不再单独设置表格的行间距和列间距了,而是复用视图的水平间距和垂直间距。原来表格的行间距和列间距会根据不同的表格方向定义不同而不同,现在统一为水平和垂直间距,不管表格的方向如何,水平间距都是定义左右的间距,垂直间距都是定义上下的间距。 - */ -@property(nonatomic ,assign, getter=subviewVSpace, setter=setSubviewVSpace:) CGFloat rowSpacing MYMETHODDEPRECATED("use subviewVSpace to instead"); -@property(nonatomic, assign, getter=subviewHSpace, setter=setSubviewHSpace:) CGFloat colSpacing MYMETHODDEPRECATED("use subviewHSpace to instead"); - - -@end diff --git a/MyLayout/Lib/MyTableLayout.m b/MyLayout/Lib/MyTableLayout.m index ee6d7fa..6b4c6bc 100644 --- a/MyLayout/Lib/MyTableLayout.m +++ b/MyLayout/Lib/MyTableLayout.m @@ -104,6 +104,8 @@ -(NSInteger)col @implementation MyTableLayout +#pragma mark -- Public Methods + +(instancetype)tableLayoutWithOrientation:(MyOrientation)orientation { return [self linearLayoutWithOrientation:orientation]; @@ -282,8 +284,7 @@ -(NSUInteger)countOfColInRow:(NSInteger)rowIndex return [self viewAtRowIndex:rowIndex].subviews.count; } -#pragma mark -- Override Method - +#pragma mark -- Override Methods -(void)setSubviewVSpace:(CGFloat)subviewVSpace @@ -343,7 +344,5 @@ -(id)createSizeClassInstance return [MyTableLayoutViewSizeClass new]; } -#pragma mark -- Deprecated Method - @end diff --git a/MyLayoutDemo/DetailViewController.m b/MyLayoutDemo/DetailViewController.m index a579096..96a5009 100644 --- a/MyLayoutDemo/DetailViewController.m +++ b/MyLayoutDemo/DetailViewController.m @@ -84,6 +84,7 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N #pragma mark -- UITableViewDelegate - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { + [tableView deselectRowAtIndexPath:indexPath animated:YES]; UIViewController *demoVC = [[self.demoVCList[indexPath.row][@"class"] alloc] init]; diff --git a/MyLayoutDemo/FOLTest7ViewController.h b/MyLayoutDemo/FOLTest7ViewController.h new file mode 100644 index 0000000..a235526 --- /dev/null +++ b/MyLayoutDemo/FOLTest7ViewController.h @@ -0,0 +1,16 @@ +// +// FOLTest7ViewController.h +// MyLayout +// +// Created by oybq on 16/2/19. +// Copyright © 2016年 YoungSoft. All rights reserved. +// + +#import + +/** + *7.FloatLayout - Alignment + */ +@interface FOLTest7ViewController : UIViewController + +@end diff --git a/MyLayoutDemo/FOLTest7ViewController.m b/MyLayoutDemo/FOLTest7ViewController.m new file mode 100644 index 0000000..9543405 --- /dev/null +++ b/MyLayoutDemo/FOLTest7ViewController.m @@ -0,0 +1,273 @@ +// +// FOLTest7ViewController.m +// MyLayout +// +// Created by oybq on 16/2/19. +// Copyright © 2016年 YoungSoft. All rights reserved. +// + +#import "FOLTest7ViewController.h" +#import "MyLayout.h" +#import "CFTool.h" + +@interface FOLTest7ViewController () + +@end + +@implementation FOLTest7ViewController + + +-(void)loadView +{ + /* + 这个例子主要给大家演示,在浮动布局中也可以支持一行(列)内的子视图的对齐方式的设置了。我们可以借助子视图的myAlignment属性来设置其在浮动布局行(列)内的对齐方式。 + 这里的对齐的标准都是以当前行(列)内最高(宽)的子视图为参考来进行(列)对齐的。 + + 在垂直浮动布局里面的子视图的行内对齐只能设置MyGravity_Vert_Top, MyGravity_Vert_Center, MyGravity_Vert_Bottom, MyGravity_Vert_Fill这几种对齐方式。 + 在水平浮动布局里面的子视图的列内对齐只能设置MyGravity_Horz_Left, MyGravity_Horz_Center, MyGravity_Horz_Right, MyGravity_Horz_Fill这几种对齐方式。 + + */ + + self.edgesForExtendedLayout = UIRectEdgeNone; + + MyLinearLayout *rootLayout = [MyLinearLayout linearLayoutWithOrientation:MyOrientation_Vert]; + rootLayout.backgroundColor = [UIColor lightGrayColor]; + rootLayout.gravity = MyGravity_Horz_Fill; //所有子视图的宽度都和自己相等。 + rootLayout.subviewVSpace = 10; + self.view = rootLayout; + + MyFloatLayout *vertLayout = [self createVertFloatLayout:rootLayout]; + vertLayout.backgroundColor = [UIColor whiteColor]; + vertLayout.weight = 0.8; //高度占用80% + [rootLayout addSubview:vertLayout]; + + MyFloatLayout *horzLayout = [self createHorzFloatLayout:rootLayout]; + horzLayout.backgroundColor = [UIColor whiteColor]; + horzLayout.weight = 0.2; //高度占用20% + [rootLayout addSubview:horzLayout]; + +} + + +- (void)viewDidLoad { + + [super viewDidLoad]; + + +} + +- (void)didReceiveMemoryWarning { + [super didReceiveMemoryWarning]; + // Dispose of any resources that can be recreated. +} + +/* +#pragma mark - Navigation + +// In a storyboard-based application, you will often want to do a little preparation before navigation +- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { + // Get the new view controller using [segue destinationViewController]. + // Pass the selected object to the new view controller. +} +*/ + +#pragma mark -- Layout Construction + +-(MyFloatLayout*)createVertFloatLayout:(MyLinearLayout*)rootLayout +{ + MyFloatLayout *floatLayout = [MyFloatLayout floatLayoutWithOrientation:MyOrientation_Vert]; + + UIImageView *logoImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"p1-12"]]; + logoImageView.layer.borderColor = [CFTool color:4].CGColor; + logoImageView.layer.borderWidth = 1; + logoImageView.myAlignment = MyGravity_Vert_Center; //在浮动的一行内垂直居中对齐。 + logoImageView.myMargin = 10; //四周的边距都设置为10. + logoImageView.mySize = CGSizeMake(80, 36); + [floatLayout addSubview:logoImageView]; + + UILabel *brandLabel = [UILabel new]; + brandLabel.text = @"千奈美官方旗舰店"; + [brandLabel sizeToFit]; + brandLabel.myAlignment = MyGravity_Vert_Center; //在浮动的一行内垂直居中对齐。 + brandLabel.myVertMargin = 10; + [floatLayout addSubview:brandLabel]; + + UIButton *attentionButton = [UIButton buttonWithType:UIButtonTypeSystem]; + [attentionButton setTitle:@"关注" forState:UIControlStateNormal]; + [attentionButton sizeToFit]; + attentionButton.reverseFloat = YES; //关注放在右边,所以浮动到右边。 + attentionButton.myMargin = 10; + attentionButton.myAlignment = MyGravity_Vert_Center; //在浮动的一行内垂直居中对齐。 + [floatLayout addSubview:attentionButton]; + + //单独一行。 + UIView *line1 = [UIView new]; + line1.backgroundColor = [CFTool color:5]; + line1.myHeight = 2; + line1.widthSize.equalTo(floatLayout.widthSize); //宽度和父视图一样宽。 + [floatLayout addSubview:line1]; + + + UIImageView *showImageView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image2"]]; + showImageView1.myMargin = 10; //四周边距是10 + showImageView1.weight = 0.6; //此时父布局的剩余宽度是屏幕,因此这里的宽度就是屏幕宽度的0.6 + showImageView1.heightSize.equalTo(showImageView1.widthSize); //高度等于宽度。 + [floatLayout addSubview:showImageView1]; + + + //绘制线 + UIView *line2 = [UIView new]; + line2.backgroundColor = [CFTool color:5]; + line2.myWidth = 2; + line2.heightSize.equalTo(showImageView1.heightSize).add(22); //高度和showImageView1高度相等,因为showImageView1还有上下分别为10的边距,还有中间横线的高度2,所以这里要增加22的高度。 + [floatLayout addSubview:line2]; + + + //右边上面的小图。 + UIImageView *showImageView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image3"]]; + showImageView2.myMargin = 10; //四周边距是10 + showImageView2.weight = 1.0; //注意这里是剩余宽度的比重,因为这个小图要占用全部的剩余空间,因此这里设置为1。 + showImageView2.heightSize.equalTo(showImageView1.heightSize).multiply(0.5).add(-10); //高度等于大图高度的一半,再减去多余的边距10 + [floatLayout addSubview:showImageView2]; + + + //中间横线。 + UIView *line3 = [UIView new]; + line3.backgroundColor = [CFTool color:5]; + line3.myHeight = 2; + line3.weight = 1.0; + [floatLayout addSubview:line3]; + + //右边下面的小图 + UIImageView *showImageView3 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image4"]]; + showImageView3.myMargin = 10; + showImageView3.weight = 1.0; + showImageView3.heightSize.equalTo(showImageView1.heightSize).multiply(0.5).add(-10); + [floatLayout addSubview:showImageView3]; + + //绘制下面的横线。 + UIView *line4 = [UIView new]; + line4.backgroundColor = [CFTool color:5]; + line4.myHeight = 2; + line4.weight = 1.0; //因为前面的所有内容都占满一行了,所以这条线是单独一行,这里是占用屏幕的全部空间了。 + line4.myBottom = 10; + [floatLayout addSubview:line4]; + + + UILabel *signatureLabel = [UILabel new]; + signatureLabel.text = @"今日已有137人签到获得好礼"; + signatureLabel.font = [CFTool font:14]; + signatureLabel.textColor = [CFTool color:4]; + [signatureLabel sizeToFit]; + signatureLabel.myHorzMargin = 10; + signatureLabel.myAlignment = MyGravity_Vert_Center; + [floatLayout addSubview:signatureLabel]; + + UIImageView *moreImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"next"]]; + moreImageView.reverseFloat = YES; + moreImageView.myHorzMargin = 10; + moreImageView.myAlignment = MyGravity_Vert_Center; + [floatLayout addSubview:moreImageView]; + + + UILabel *moreLabel = [UILabel new]; + moreLabel.text = @"进店看看"; + [moreLabel sizeToFit]; + moreLabel.reverseFloat = YES; + moreLabel.myAlignment = MyGravity_Vert_Center; + [floatLayout addSubview:moreLabel]; + + + UIView *line5 = [UIView new]; + line5.backgroundColor = [CFTool color:5]; + line5.myHeight = 2; + line5.myVertMargin = 10; + line5.widthSize.equalTo(floatLayout.widthSize); + [floatLayout addSubview:line5]; + + + // + UIImageView *commentImageView1 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"minions4"]]; + commentImageView1.myAlignment = MyGravity_Vert_Fill; //这里使用填充对齐,表明会和这行里面高度最高的那个子视图的高度保持一致。 + commentImageView1.myLeft = 10; + [floatLayout addSubview:commentImageView1]; + + UIImageView *commentImageView2 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"minions3"]]; + commentImageView2.myAlignment = MyGravity_Vert_Fill; //这里使用填充对齐,表明会和这行里面高度最高的那个子视图的高度保持一致。 + commentImageView2.myLeft = 10; + [floatLayout addSubview:commentImageView2]; + + UIImageView *commentImageView3 = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"minions3"]]; + commentImageView3.myLeft = 10; + [floatLayout addSubview:commentImageView3]; + + + for (int i = 0; i < 4; i++) + { + UIImageView *starImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"section2"]]; + starImageView.mySize = CGSizeMake(20, 20); + starImageView.myAlignment = MyGravity_Vert_Bottom; //这里底部对齐,表明子视图和一行内最高的子视图保持底部对齐。 + starImageView.myLeft = 5; + [floatLayout addSubview:starImageView]; + } + + + UIView *line6 = [UIView new]; + line6.backgroundColor = [CFTool color:5]; + line6.myHeight = 2; + line6.widthSize.equalTo(floatLayout.widthSize); + [floatLayout addSubview:line6]; + + + + + return floatLayout; + +} + +-(MyFloatLayout*)createHorzFloatLayout:(MyLinearLayout*)rootLayout +{ + MyFloatLayout *floatLayout = [MyFloatLayout floatLayoutWithOrientation:MyOrientation_Horz]; + floatLayout.padding = UIEdgeInsetsMake(10, 10, 10, 10); + floatLayout.subviewSpace = 10; + + NSArray *names = @[@"minions1",@"minions3",@"minions2",@"minions4",@"p4-23",@"p4-11"]; + for (int i = 0; i < 6; i++) + { + UIImageView *imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:names[i]]]; + imageView.layer.borderWidth = 0.5; + imageView.layer.borderColor = [CFTool color:6].CGColor; + imageView.heightSize.equalTo(floatLayout.heightSize).multiply(0.5).add(-5); //高度等于父视图的高度的一半,因为设置了每个子视图的间距为10,所以这里要减去5。 + if (i % 2 == 0) + {//这句话的意思一列显示两个子视图,所以当索引下标为偶数时就是换列处理。 + imageView.clearFloat = YES; + } + + //水平填充,每列两个子视图,每列的对齐方式都不一样。 + switch (i) { + case 0: + case 1: + imageView.myAlignment = MyGravity_Horz_Center; + break; + case 2: + case 3: + imageView.myAlignment = MyGravity_Horz_Right; + break; + case 4: + case 5: + imageView.myAlignment = MyGravity_Horz_Fill; + default: + break; + } + + [floatLayout addSubview:imageView]; + + } + + + return floatLayout; + + +} + +@end diff --git a/MyLayoutDemo/Info.plist b/MyLayoutDemo/Info.plist index 141a517..0ef0d7f 100644 --- a/MyLayoutDemo/Info.plist +++ b/MyLayoutDemo/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.5.0 + 1.5.1 CFBundleSignature ???? CFBundleVersion diff --git a/MyLayoutDemo/ViewController.m b/MyLayoutDemo/ViewController.m index d3bc3d3..b8b8b9b 100644 --- a/MyLayoutDemo/ViewController.m +++ b/MyLayoutDemo/ViewController.m @@ -58,6 +58,8 @@ #import "FOLTest4ViewController.h" #import "FOLTest5ViewController.h" #import "FOLTest6ViewController.h" +#import "FOLTest7ViewController.h" + #import "PLTest1ViewController.h" #import "PLTest2ViewController.h" @@ -198,6 +200,9 @@ -(NSArray*)demoTypeList }, @{@"title":NSLocalizedString(@"6.FloatLayout - User Profiles", @""), @"class":[FOLTest6ViewController class] + }, + @{@"title":NSLocalizedString(@"7.FloatLayout - Alignment", @""), + @"class":[FOLTest7ViewController class] } ] }, diff --git a/MyLayoutDemo/zh-Hans.lproj/Localizable.strings b/MyLayoutDemo/zh-Hans.lproj/Localizable.strings index 15c45b3..d843836 100644 --- a/MyLayoutDemo/zh-Hans.lproj/Localizable.strings +++ b/MyLayoutDemo/zh-Hans.lproj/Localizable.strings @@ -38,6 +38,7 @@ "4.FloatLayout - Tag cloud" = "4.浮动布局-标签流"; "5.FloatLayout - Title & Description" = "5.浮动布局-左右排列的文本"; "6.FloatLayout - User Profiles"="6.浮动布局-各种用户配置的实现"; +"7.FloatLayout - Alignment"="7.浮动布局-行内对齐"; "1.PathLayout - Animations" = "1.路径布局-各种动画效果"; "2.PathLayout - Curves"="2.路径布局-各种函数曲线"; "3.PathLayout - Menu in Circle"="3.路径布局-圆环型菜单"; diff --git a/README.md b/README.md index dbd5df4..b9ec76f 100644 --- a/README.md +++ b/README.md @@ -614,7 +614,7 @@ To integrate MyLayout into your Xcode project using CocoaPods, specify it in you source 'https://github.com/CocoaPods/Specs.git' platform :ios, '7.0' -pod 'MyLayout', '~> 1.5.0' +pod 'MyLayout', '~> 1.5.1' ``` Then, run the following command: diff --git a/README.zh.md b/README.zh.md index 3f296e4..1a3bd7d 100644 --- a/README.zh.md +++ b/README.zh.md @@ -622,7 +622,7 @@ $ gem install cocoapods source 'https://github.com/CocoaPods/Specs.git' platform :ios, '7.0' -pod 'MyLayout', '~> 1.5.0' +pod 'MyLayout', '~> 1.5.1' ``` 然后运行如下命令: