diff --git a/Masonry.xcodeproj/project.pbxproj b/Masonry.xcodeproj/project.pbxproj index 1d7d2dab..6d711e54 100644 --- a/Masonry.xcodeproj/project.pbxproj +++ b/Masonry.xcodeproj/project.pbxproj @@ -57,6 +57,10 @@ 4473548E1B39F772004DACCB /* ViewController+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4473548C1B39F772004DACCB /* ViewController+MASAdditions.m */; }; 447354921B3A18B3004DACCB /* ViewController+MASAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 4473548C1B39F772004DACCB /* ViewController+MASAdditions.m */; }; 447354931B3A18B9004DACCB /* ViewController+MASAdditions.h in Headers */ = {isa = PBXBuildFile; fileRef = 4473548B1B39F772004DACCB /* ViewController+MASAdditions.h */; settings = {ATTRIBUTES = (Public, ); }; }; + 8ABCACFA254FFD5400E68BB4 /* NSArray+MASShorthandAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ABCACF9254FFD5400E68BB4 /* NSArray+MASShorthandAdditions.m */; }; + 8ABCACFB254FFD5400E68BB4 /* NSArray+MASShorthandAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ABCACF9254FFD5400E68BB4 /* NSArray+MASShorthandAdditions.m */; }; + 8ABCACFF254FFDC300E68BB4 /* View+MASShorthandAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ABCACFE254FFDC300E68BB4 /* View+MASShorthandAdditions.m */; }; + 8ABCAD00254FFDC300E68BB4 /* View+MASShorthandAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 8ABCACFE254FFDC300E68BB4 /* View+MASShorthandAdditions.m */; }; /* End PBXBuildFile section */ /* Begin PBXFileReference section */ @@ -88,6 +92,8 @@ 3AED06271AD5A1400053CC65 /* Masonry.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Masonry.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 4473548B1B39F772004DACCB /* ViewController+MASAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ViewController+MASAdditions.h"; sourceTree = ""; }; 4473548C1B39F772004DACCB /* ViewController+MASAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "ViewController+MASAdditions.m"; sourceTree = ""; }; + 8ABCACF9254FFD5400E68BB4 /* NSArray+MASShorthandAdditions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "NSArray+MASShorthandAdditions.m"; sourceTree = ""; }; + 8ABCACFE254FFDC300E68BB4 /* View+MASShorthandAdditions.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "View+MASShorthandAdditions.m"; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -133,11 +139,13 @@ 3AED05EF1AD5A0470053CC65 /* View+MASAdditions.h */, 3AED05F01AD5A0470053CC65 /* View+MASAdditions.m */, 3AED05F11AD5A0470053CC65 /* View+MASShorthandAdditions.h */, + 8ABCACFE254FFDC300E68BB4 /* View+MASShorthandAdditions.m */, 4473548B1B39F772004DACCB /* ViewController+MASAdditions.h */, 4473548C1B39F772004DACCB /* ViewController+MASAdditions.m */, 3AED05EA1AD5A0470053CC65 /* NSArray+MASAdditions.h */, 3AED05EB1AD5A0470053CC65 /* NSArray+MASAdditions.m */, 3AED05EC1AD5A0470053CC65 /* NSArray+MASShorthandAdditions.h */, + 8ABCACF9254FFD5400E68BB4 /* NSArray+MASShorthandAdditions.m */, 3AED05DE1AD5A0470053CC65 /* MASConstraint.h */, 3AED05E01AD5A0470053CC65 /* MASConstraint+Private.h */, 3AED05DF1AD5A0470053CC65 /* MASConstraint.m */, @@ -271,6 +279,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = 3AED05AD1AD59FD40053CC65; @@ -314,6 +323,8 @@ 3AED05FF1AD5A0470053CC65 /* MASViewConstraint.m in Sources */, 3AED05F31AD5A0470053CC65 /* MASCompositeConstraint.m in Sources */, 3AED05F81AD5A0470053CC65 /* MASConstraintMaker.m in Sources */, + 8ABCACFF254FFDC300E68BB4 /* View+MASShorthandAdditions.m in Sources */, + 8ABCACFA254FFD5400E68BB4 /* NSArray+MASShorthandAdditions.m in Sources */, 3AED06041AD5A0470053CC65 /* NSLayoutConstraint+MASDebugAdditions.m in Sources */, 3AED06061AD5A0470053CC65 /* View+MASAdditions.m in Sources */, ); @@ -331,6 +342,8 @@ 3AED060F1AD5A1400053CC65 /* MASCompositeConstraint.m in Sources */, 447354921B3A18B3004DACCB /* ViewController+MASAdditions.m in Sources */, 3AED06101AD5A1400053CC65 /* MASConstraintMaker.m in Sources */, + 8ABCAD00254FFDC300E68BB4 /* View+MASShorthandAdditions.m in Sources */, + 8ABCACFB254FFD5400E68BB4 /* NSArray+MASShorthandAdditions.m in Sources */, 3AED06111AD5A1400053CC65 /* NSLayoutConstraint+MASDebugAdditions.m in Sources */, 3AED06121AD5A1400053CC65 /* View+MASAdditions.m in Sources */, ); diff --git a/Masonry/NSArray+MASAdditions.m b/Masonry/NSArray+MASAdditions.m index 831d8cda..67be5844 100644 --- a/Masonry/NSArray+MASAdditions.m +++ b/Masonry/NSArray+MASAdditions.m @@ -9,6 +9,8 @@ #import "NSArray+MASAdditions.h" #import "View+MASAdditions.h" + + @implementation NSArray (MASAdditions) - (NSArray *)mas_makeConstraints:(void(^)(MASConstraintMaker *make))block { @@ -160,3 +162,4 @@ - (MAS_VIEW *)mas_commonSuperviewOfViews } @end + diff --git a/Masonry/NSArray+MASShorthandAdditions.h b/Masonry/NSArray+MASShorthandAdditions.h index 8b473697..cd63f437 100644 --- a/Masonry/NSArray+MASShorthandAdditions.h +++ b/Masonry/NSArray+MASShorthandAdditions.h @@ -22,20 +22,4 @@ @end -@implementation NSArray (MASShorthandAdditions) - -- (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { - return [self mas_makeConstraints:block]; -} - -- (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { - return [self mas_updateConstraints:block]; -} - -- (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { - return [self mas_remakeConstraints:block]; -} - -@end - #endif diff --git a/Masonry/NSArray+MASShorthandAdditions.m b/Masonry/NSArray+MASShorthandAdditions.m new file mode 100644 index 00000000..0ca03441 --- /dev/null +++ b/Masonry/NSArray+MASShorthandAdditions.m @@ -0,0 +1,27 @@ +// +// NSArray+MASShorthandAdditions.m +// Masonry +// +// Created by matt on 2020/11/2. +// Copyright © 2020 Jonas Budelmann. All rights reserved. +// + +#import "NSArray+MASShorthandAdditions.h" + +#ifdef MAS_SHORTHAND +@implementation NSArray (MASShorthandAdditions) + +- (NSArray *)makeConstraints:(void(^)(MASConstraintMaker *))block { + return [self mas_makeConstraints:block]; +} + +- (NSArray *)updateConstraints:(void(^)(MASConstraintMaker *))block { + return [self mas_updateConstraints:block]; +} + +- (NSArray *)remakeConstraints:(void(^)(MASConstraintMaker *))block { + return [self mas_remakeConstraints:block]; +} + +@end +#endif diff --git a/Masonry/View+MASShorthandAdditions.h b/Masonry/View+MASShorthandAdditions.h index 8e375ee3..35f50989 100644 --- a/Masonry/View+MASShorthandAdditions.h +++ b/Masonry/View+MASShorthandAdditions.h @@ -66,73 +66,4 @@ @end -#define MAS_ATTR_FORWARD(attr) \ -- (MASViewAttribute *)attr { \ - return [self mas_##attr]; \ -} - -#define MAS_ATTR_FORWARD_AVAILABLE(attr, available) \ -- (MASViewAttribute *)attr available { \ - return [self mas_##attr]; \ -} - -@implementation MAS_VIEW (MASShorthandAdditions) - -MAS_ATTR_FORWARD(top); -MAS_ATTR_FORWARD(left); -MAS_ATTR_FORWARD(bottom); -MAS_ATTR_FORWARD(right); -MAS_ATTR_FORWARD(leading); -MAS_ATTR_FORWARD(trailing); -MAS_ATTR_FORWARD(width); -MAS_ATTR_FORWARD(height); -MAS_ATTR_FORWARD(centerX); -MAS_ATTR_FORWARD(centerY); -MAS_ATTR_FORWARD(baseline); - -MAS_ATTR_FORWARD(firstBaseline); -MAS_ATTR_FORWARD(lastBaseline); - -#if TARGET_OS_IPHONE || TARGET_OS_TV - -MAS_ATTR_FORWARD(leftMargin); -MAS_ATTR_FORWARD(rightMargin); -MAS_ATTR_FORWARD(topMargin); -MAS_ATTR_FORWARD(bottomMargin); -MAS_ATTR_FORWARD(leadingMargin); -MAS_ATTR_FORWARD(trailingMargin); -MAS_ATTR_FORWARD(centerXWithinMargins); -MAS_ATTR_FORWARD(centerYWithinMargins); - -MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideLeading, NS_AVAILABLE_IOS(11.0)); -MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideTrailing, NS_AVAILABLE_IOS(11.0)); -MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideLeft, NS_AVAILABLE_IOS(11.0)); -MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideRight, NS_AVAILABLE_IOS(11.0)); -MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideTop, NS_AVAILABLE_IOS(11.0)); -MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideBottom, NS_AVAILABLE_IOS(11.0)); -MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideWidth, NS_AVAILABLE_IOS(11.0)); -MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideHeight, NS_AVAILABLE_IOS(11.0)); -MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideCenterX, NS_AVAILABLE_IOS(11.0)); -MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideCenterY, NS_AVAILABLE_IOS(11.0)); - -#endif - -- (MASViewAttribute *(^)(NSLayoutAttribute))attribute { - return [self mas_attribute]; -} - -- (NSArray *)makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { - return [self mas_makeConstraints:block]; -} - -- (NSArray *)updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { - return [self mas_updateConstraints:block]; -} - -- (NSArray *)remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { - return [self mas_remakeConstraints:block]; -} - -@end - #endif diff --git a/Masonry/View+MASShorthandAdditions.m b/Masonry/View+MASShorthandAdditions.m new file mode 100644 index 00000000..b112147d --- /dev/null +++ b/Masonry/View+MASShorthandAdditions.m @@ -0,0 +1,81 @@ +// +// View+MASShorthandAdditions.m +// Masonry +// +// Created by matt on 2020/11/2. +// Copyright © 2020 Jonas Budelmann. All rights reserved. +// + +#import "View+MASShorthandAdditions.h" + +#ifdef MAS_SHORTHAND + +#define MAS_ATTR_FORWARD(attr) \ +- (MASViewAttribute *)attr { \ + return [self mas_##attr]; \ +} + +#define MAS_ATTR_FORWARD_AVAILABLE(attr, available) \ +- (MASViewAttribute *)attr available { \ + return [self mas_##attr]; \ +} + +@implementation MAS_VIEW (MASShorthandAdditions) + +MAS_ATTR_FORWARD(top); +MAS_ATTR_FORWARD(left); +MAS_ATTR_FORWARD(bottom); +MAS_ATTR_FORWARD(right); +MAS_ATTR_FORWARD(leading); +MAS_ATTR_FORWARD(trailing); +MAS_ATTR_FORWARD(width); +MAS_ATTR_FORWARD(height); +MAS_ATTR_FORWARD(centerX); +MAS_ATTR_FORWARD(centerY); +MAS_ATTR_FORWARD(baseline); + +MAS_ATTR_FORWARD(firstBaseline); +MAS_ATTR_FORWARD(lastBaseline); + +#if TARGET_OS_IPHONE || TARGET_OS_TV + +MAS_ATTR_FORWARD(leftMargin); +MAS_ATTR_FORWARD(rightMargin); +MAS_ATTR_FORWARD(topMargin); +MAS_ATTR_FORWARD(bottomMargin); +MAS_ATTR_FORWARD(leadingMargin); +MAS_ATTR_FORWARD(trailingMargin); +MAS_ATTR_FORWARD(centerXWithinMargins); +MAS_ATTR_FORWARD(centerYWithinMargins); + +MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideLeading, NS_AVAILABLE_IOS(11.0)); +MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideTrailing, NS_AVAILABLE_IOS(11.0)); +MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideLeft, NS_AVAILABLE_IOS(11.0)); +MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideRight, NS_AVAILABLE_IOS(11.0)); +MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideTop, NS_AVAILABLE_IOS(11.0)); +MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideBottom, NS_AVAILABLE_IOS(11.0)); +MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideWidth, NS_AVAILABLE_IOS(11.0)); +MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideHeight, NS_AVAILABLE_IOS(11.0)); +MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideCenterX, NS_AVAILABLE_IOS(11.0)); +MAS_ATTR_FORWARD_AVAILABLE(safeAreaLayoutGuideCenterY, NS_AVAILABLE_IOS(11.0)); + +#endif + +- (MASViewAttribute *(^)(NSLayoutAttribute))attribute { + return [self mas_attribute]; +} + +- (NSArray *)makeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { + return [self mas_makeConstraints:block]; +} + +- (NSArray *)updateConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { + return [self mas_updateConstraints:block]; +} + +- (NSArray *)remakeConstraints:(void(NS_NOESCAPE ^)(MASConstraintMaker *))block { + return [self mas_remakeConstraints:block]; +} + +@end +#endif