This commit is contained in:
giuseppenuc committed 2016-12-20 16:02:27 +01:00
1 parent 1bf4b9ef1d
commit 4e66c377fd
664 files changed
+14818 -10172

No files matched your search

@@ -29,7 +29,7 @@
#import "PureLayoutDefines.h"
__PL_ASSUME_NONNULL_BEGIN
PL__ASSUME_NONNULL_BEGIN
#pragma mark ALView+PureLayout
@@ -54,20 +54,20 @@ __PL_ASSUME_NONNULL_BEGIN
#pragma mark Center & Align in Superview
/** Centers the view in its superview. */
- (__NSArray_of(NSLayoutConstraint *) *)autoCenterInSuperview;
- (PL__NSArray_of(NSLayoutConstraint *) *)autoCenterInSuperview;
/** Aligns the view to the same axis of its superview. */
- (NSLayoutConstraint *)autoAlignAxisToSuperviewAxis:(ALAxis)axis;
#if __PureLayout_MinBaseSDK_iOS_8_0
#if PL__PureLayout_MinBaseSDK_iOS_8_0
/** Centers the view in its superview's margins. Available in iOS 8.0 and later. */
- (__NSArray_of(NSLayoutConstraint *) *)autoCenterInSuperviewMargins;
- (PL__NSArray_of(NSLayoutConstraint *) *)autoCenterInSuperviewMargins;
/** Aligns the view to the corresponding margin axis of its superview. Available in iOS 8.0 and later. */
- (NSLayoutConstraint *)autoAlignAxisToSuperviewMarginAxis:(ALAxis)axis;
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 */
#pragma mark Pin Edges to Superview
@@ -82,15 +82,15 @@ __PL_ASSUME_NONNULL_BEGIN
- (NSLayoutConstraint *)autoPinEdgeToSuperviewEdge:(ALEdge)edge withInset:(CGFloat)inset relation:(NSLayoutRelation)relation;
/** Pins the edges of the view to the edges of its superview. */
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdges;
- (PL__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdges;
/** Pins the edges of the view to the edges of its superview with the given edge insets. */
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdgesWithInsets:(ALEdgeInsets)insets;
- (PL__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdgesWithInsets:(ALEdgeInsets)insets;
/** Pins 3 of the 4 edges of the view to the edges of its superview with the given edge insets, excluding one edge. */
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdgesWithInsets:(ALEdgeInsets)insets excludingEdge:(ALEdge)edge;
- (PL__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdgesWithInsets:(ALEdgeInsets)insets excludingEdge:(ALEdge)edge;
#if __PureLayout_MinBaseSDK_iOS_8_0
#if PL__PureLayout_MinBaseSDK_iOS_8_0
/** Pins the given edge of the view to the corresponding margin of its superview. Available in iOS 8.0 and later. */
- (NSLayoutConstraint *)autoPinEdgeToSuperviewMargin:(ALEdge)edge;
@@ -99,12 +99,12 @@ __PL_ASSUME_NONNULL_BEGIN
- (NSLayoutConstraint *)autoPinEdgeToSuperviewMargin:(ALEdge)edge relation:(NSLayoutRelation)relation;
/** Pins the edges of the view to the margins of its superview. Available in iOS 8.0 and later. */
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewMargins;
- (PL__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewMargins;
/** Pins 3 of the 4 edges of the view to the margins of its superview excluding one edge. Available in iOS 8.0 and later. */
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewMarginsExcludingEdge:(ALEdge)edge;
- (PL__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewMarginsExcludingEdge:(ALEdge)edge;
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 */
#pragma mark Pin Edges
@@ -152,7 +152,7 @@ __PL_ASSUME_NONNULL_BEGIN
#pragma mark Set Dimensions
/** Sets the view to a specific size. */
- (__NSArray_of(NSLayoutConstraint *) *)autoSetDimensionsToSize:(CGSize)size;
- (PL__NSArray_of(NSLayoutConstraint *) *)autoSetDimensionsToSize:(CGSize)size;
/** Sets the given dimension of the view to a specific size. */
- (NSLayoutConstraint *)autoSetDimension:(ALDimension)dimension toSize:(CGFloat)size;
@@ -210,4 +210,4 @@ __PL_ASSUME_NONNULL_BEGIN
@end
__PL_ASSUME_NONNULL_END
PL__ASSUME_NONNULL_END
@@ -78,7 +78,7 @@
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoCenterInSuperview
- (PL__NSArray_of(NSLayoutConstraint *) *)autoCenterInSuperview
{
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
[constraints addObject:[self autoAlignAxisToSuperviewAxis:ALAxisHorizontal]];
@@ -100,14 +100,14 @@
return [self autoConstrainAttribute:(ALAttribute)axis toAttribute:(ALAttribute)axis ofView:superview];
}
#if __PureLayout_MinBaseSDK_iOS_8_0
#if PL__PureLayout_MinBaseSDK_iOS_8_0
/**
Centers the view in its superview, taking into account the layout margins of both the view and its superview.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoCenterInSuperviewMargins
- (PL__NSArray_of(NSLayoutConstraint *) *)autoCenterInSuperviewMargins
{
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
[constraints addObject:[self autoAlignAxisToSuperviewMarginAxis:ALAxisHorizontal]];
@@ -130,7 +130,7 @@
return [self autoConstrainAttribute:(ALAttribute)axis toAttribute:(ALAttribute)marginAxis ofView:superview];
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 */
#pragma mark Pin Edges to Superview
@@ -188,7 +188,7 @@
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdges
- (PL__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdges
{
return [self autoPinEdgesToSuperviewEdgesWithInsets:ALEdgeInsetsZero];
}
@@ -200,7 +200,7 @@
@param insets The insets for this view's edges from its superview's edges.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdgesWithInsets:(ALEdgeInsets)insets
- (PL__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdgesWithInsets:(ALEdgeInsets)insets
{
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
[constraints addObject:[self autoPinEdgeToSuperviewEdge:ALEdgeTop withInset:insets.top]];
@@ -219,7 +219,7 @@
@param edge The edge of this view to exclude in pinning to its superview; this method will not apply any constraint to it.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdgesWithInsets:(ALEdgeInsets)insets excludingEdge:(ALEdge)edge
- (PL__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewEdgesWithInsets:(ALEdgeInsets)insets excludingEdge:(ALEdge)edge
{
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
if (edge != ALEdgeTop) {
@@ -237,7 +237,7 @@
return constraints;
}
#if __PureLayout_MinBaseSDK_iOS_8_0
#if PL__PureLayout_MinBaseSDK_iOS_8_0
/**
Pins the given edge of the view to the corresponding margin of its superview.
@@ -279,7 +279,7 @@
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewMargins
- (PL__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewMargins
{
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
[constraints addObject:[self autoPinEdgeToSuperviewMargin:ALEdgeTop]];
@@ -295,7 +295,7 @@
@param edge The edge of this view to exclude in pinning to its superview; this method will not apply any constraint to it.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewMarginsExcludingEdge:(ALEdge)edge
- (PL__NSArray_of(NSLayoutConstraint *) *)autoPinEdgesToSuperviewMarginsExcludingEdge:(ALEdge)edge
{
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
if (edge != ALEdgeTop) {
@@ -313,7 +313,7 @@
return constraints;
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 */
#pragma mark Pin Edges
@@ -484,7 +484,7 @@
@param size The size to set this view's dimensions to.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoSetDimensionsToSize:(CGSize)size
- (PL__NSArray_of(NSLayoutConstraint *) *)autoSetDimensionsToSize:(CGSize)size
{
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
[constraints addObject:[self autoSetDimension:ALDimensionWidth toSize:size.width]];
@@ -674,7 +674,7 @@
- (NSLayoutConstraint *)autoPinToTopLayoutGuideOfViewController:(UIViewController *)viewController withInset:(CGFloat)inset relation:(NSLayoutRelation)relation
{
if (__PureLayout_MinSysVer_iOS_7_0) {
if (PL__PureLayout_MinSysVer_iOS_7_0) {
self.translatesAutoresizingMaskIntoConstraints = NO;
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeTop relatedBy:relation toItem:viewController.topLayoutGuide attribute:NSLayoutAttributeBottom multiplier:1.0 constant:inset];
[viewController.view al_addConstraint:constraint]; // Can't use autoInstall because the layout guide is not a view
@@ -708,7 +708,7 @@
} else if (relation == NSLayoutRelationGreaterThanOrEqual) {
relation = NSLayoutRelationLessThanOrEqual;
}
if (__PureLayout_MinSysVer_iOS_7_0) {
if (PL__PureLayout_MinSysVer_iOS_7_0) {
self.translatesAutoresizingMaskIntoConstraints = NO;
NSLayoutConstraint *constraint = [NSLayoutConstraint constraintWithItem:self attribute:NSLayoutAttributeBottom relatedBy:relation toItem:viewController.bottomLayoutGuide attribute:NSLayoutAttributeTop multiplier:1.0 constant:inset];
[viewController.view al_addConstraint:constraint]; // Can't use autoInstall because the layout guide is not a view
@@ -793,13 +793,13 @@
NSAssert(axis != ALAxisVertical, @"Cannot align views that are distributed vertically with ALAttributeBaseline.");
constraint = [self autoAlignAxis:ALAxisBaseline toSameAxisOfView:otherView];
break;
#if __PureLayout_MinBaseSDK_iOS_8_0
#if PL__PureLayout_MinBaseSDK_iOS_8_0
case ALAttributeFirstBaseline:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALAttributeFirstBaseline is only supported on iOS 8.0 or higher.");
NSAssert(PL__PureLayout_MinSysVer_iOS_8_0, @"ALAttributeFirstBaseline is only supported on iOS 8.0 or higher.");
NSAssert(axis != ALAxisVertical, @"Cannot align views that are distributed vertically with ALAttributeFirstBaseline.");
constraint = [self autoAlignAxis:ALAxisFirstBaseline toSameAxisOfView:otherView];
break;
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 */
case ALAttributeTop:
NSAssert(axis != ALAxisVertical, @"Cannot align views that are distributed vertically with ALAttributeTop.");
constraint = [self autoPinEdge:ALEdgeTop toEdge:ALEdgeTop ofView:otherView];
@@ -828,7 +828,7 @@
// All of the below attributes are invalid as alignment options. Listing them explicitly (even though they just fall through to the default case) to avoid an incomplete switch statement warning from the compiler.
case ALAttributeWidth:
case ALAttributeHeight:
#if __PureLayout_MinBaseSDK_iOS_8_0
#if PL__PureLayout_MinBaseSDK_iOS_8_0
case ALAttributeMarginLeft:
case ALAttributeMarginRight:
case ALAttributeMarginTop:
@@ -837,7 +837,7 @@
case ALAttributeMarginTrailing:
case ALAttributeMarginAxisVertical:
case ALAttributeMarginAxisHorizontal:
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 */
default:
NSAssert(nil, @"Unsupported attribute for alignment.");
break;
@@ -29,7 +29,7 @@
#import "PureLayoutDefines.h"
__PL_ASSUME_NONNULL_BEGIN
PL__ASSUME_NONNULL_BEGIN
#pragma mark NSArray+PureLayout
@@ -49,48 +49,48 @@ __PL_ASSUME_NONNULL_BEGIN
/** Deactivates the constraints in this array. */
- (void)autoRemoveConstraints;
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
#if PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10
/** Sets the string as the identifier for the constraints in this array. Available in iOS 7.0 and OS X 10.9 and later. */
- (instancetype)autoIdentifyConstraints:(NSString *)identifier;
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10 */
#pragma mark Array of Views
/** Aligns views in this array to one another along a given edge. */
- (__NSArray_of(NSLayoutConstraint *) *)autoAlignViewsToEdge:(ALEdge)edge;
- (PL__NSArray_of(NSLayoutConstraint *) *)autoAlignViewsToEdge:(ALEdge)edge;
/** Aligns views in this array to one another along a given axis. */
- (__NSArray_of(NSLayoutConstraint *) *)autoAlignViewsToAxis:(ALAxis)axis;
- (PL__NSArray_of(NSLayoutConstraint *) *)autoAlignViewsToAxis:(ALAxis)axis;
/** Matches a given dimension of all the views in this array. */
- (__NSArray_of(NSLayoutConstraint *) *)autoMatchViewsDimension:(ALDimension)dimension;
- (PL__NSArray_of(NSLayoutConstraint *) *)autoMatchViewsDimension:(ALDimension)dimension;
/** Sets the given dimension of all the views in this array to a given size. */
- (__NSArray_of(NSLayoutConstraint *) *)autoSetViewsDimension:(ALDimension)dimension toSize:(CGFloat)size;
- (PL__NSArray_of(NSLayoutConstraint *) *)autoSetViewsDimension:(ALDimension)dimension toSize:(CGFloat)size;
/** Sets all of the views in this array to a given size. */
- (__NSArray_of(NSLayoutConstraint *) *)autoSetViewsDimensionsToSize:(CGSize)size;
- (PL__NSArray_of(NSLayoutConstraint *) *)autoSetViewsDimensionsToSize:(CGSize)size;
/** Distributes the views in this array equally along the selected axis in their superview.
Views will be the same size (variable) in the dimension along the axis and will have spacing (fixed) between them. */
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
- (PL__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSpacing:(CGFloat)spacing;
/** Distributes the views in this array equally along the selected axis in their superview.
Views will be the same size (variable) in the dimension along the axis and will have spacing (fixed) between them, with optional insets from the first and last views to their superview. */
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
- (PL__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSpacing:(CGFloat)spacing
insetSpacing:(BOOL)shouldSpaceInsets;
/** Distributes the views in this array equally along the selected axis in their superview.
Views will have spacing (fixed) between them, with optional insets from the first and last views to their superview, and optionally constrained to the same size in the dimension along the axis. */
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
- (PL__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSpacing:(CGFloat)spacing
insetSpacing:(BOOL)shouldSpaceInsets
@@ -99,17 +99,17 @@ __PL_ASSUME_NONNULL_BEGIN
/** Distributes the views in this array equally along the selected axis in their superview.
Views will be the same size (fixed) in the dimension along the axis and will have spacing (variable) between them. */
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
- (PL__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSize:(CGFloat)size;
/** Distributes the views in this array equally along the selected axis in their superview.
Views will be the same size (fixed) in the dimension along the axis and will have spacing (variable) between them, with optional insets from the first and last views to their superview. */
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
- (PL__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSize:(CGFloat)size
insetSpacing:(BOOL)shouldSpaceInsets;
@end
__PL_ASSUME_NONNULL_END
PL__ASSUME_NONNULL_END
@@ -44,7 +44,7 @@
*/
- (void)autoInstallConstraints
{
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
#if PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10
if ([NSLayoutConstraint respondsToSelector:@selector(activateConstraints:)]) {
for (id object in self) {
if ([object isKindOfClass:[NSLayoutConstraint class]]) {
@@ -58,7 +58,7 @@
}
return;
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10 */
for (id object in self) {
if ([object isKindOfClass:[NSLayoutConstraint class]]) {
@@ -72,12 +72,12 @@
*/
- (void)autoRemoveConstraints
{
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
#if PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10
if ([NSLayoutConstraint respondsToSelector:@selector(deactivateConstraints:)]) {
[NSLayoutConstraint deactivateConstraints:self];
return;
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10 */
for (id object in self) {
if ([object isKindOfClass:[NSLayoutConstraint class]]) {
@@ -86,7 +86,7 @@
}
}
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
#if PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10
/**
Sets the string as the identifier for the constraints in this array. Available in iOS 7.0 and OS X 10.9 and later.
@@ -106,7 +106,7 @@
return self;
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10 */
#pragma mark Array of Views
@@ -118,7 +118,7 @@
@param edge The edge to which the views will be aligned.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoAlignViewsToEdge:(ALEdge)edge
- (PL__NSArray_of(NSLayoutConstraint *) *)autoAlignViewsToEdge:(ALEdge)edge
{
NSAssert([self al_containsMinimumNumberOfViews:2], @"This array must contain at least 2 views.");
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
@@ -143,7 +143,7 @@
@param axis The axis to which the views will be aligned.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoAlignViewsToAxis:(ALAxis)axis
- (PL__NSArray_of(NSLayoutConstraint *) *)autoAlignViewsToAxis:(ALAxis)axis
{
NSAssert([self al_containsMinimumNumberOfViews:2], @"This array must contain at least 2 views.");
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
@@ -168,7 +168,7 @@
@param dimension The dimension to match for all of the views.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoMatchViewsDimension:(ALDimension)dimension
- (PL__NSArray_of(NSLayoutConstraint *) *)autoMatchViewsDimension:(ALDimension)dimension
{
NSAssert([self al_containsMinimumNumberOfViews:2], @"This array must contain at least 2 views.");
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
@@ -194,7 +194,7 @@
@param size The size to set the given dimension of each view to.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoSetViewsDimension:(ALDimension)dimension toSize:(CGFloat)size
- (PL__NSArray_of(NSLayoutConstraint *) *)autoSetViewsDimension:(ALDimension)dimension toSize:(CGFloat)size
{
NSAssert([self al_containsMinimumNumberOfViews:1], @"This array must contain at least 1 view.");
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
@@ -215,7 +215,7 @@
@param size The size to set each view's dimensions to.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoSetViewsDimensionsToSize:(CGSize)size
- (PL__NSArray_of(NSLayoutConstraint *) *)autoSetViewsDimensionsToSize:(CGSize)size
{
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
[constraints addObjectsFromArray:[self autoSetViewsDimension:ALDimensionWidth toSize:size.width]];
@@ -234,7 +234,7 @@
@param spacing The fixed amount of spacing between each view.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
- (PL__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSpacing:(CGFloat)spacing
{
@@ -255,7 +255,7 @@
@param shouldSpaceInsets Whether the first and last views should be equally inset from their superview.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
- (PL__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSpacing:(CGFloat)spacing
insetSpacing:(BOOL)shouldSpaceInsets
@@ -280,7 +280,7 @@
NOTE: All views must specify an intrinsic content size if passing NO, otherwise the layout will be ambiguous!
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
- (PL__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSpacing:(CGFloat)spacing
insetSpacing:(BOOL)shouldSpaceInsets
@@ -292,9 +292,9 @@
switch (axis) {
case ALAxisHorizontal:
case ALAxisBaseline: // same value as ALAxisLastBaseline
#if __PureLayout_MinBaseSDK_iOS_8_0
#if PL__PureLayout_MinBaseSDK_iOS_8_0
case ALAxisFirstBaseline:
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 */
matchedDimension = ALDimensionWidth;
firstEdge = ALEdgeLeading;
lastEdge = ALEdgeTrailing;
@@ -349,7 +349,7 @@
@param size The fixed size of each view in the dimension along the given axis.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
- (PL__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSize:(CGFloat)size
{
@@ -370,7 +370,7 @@
@param shouldSpaceInsets Whether the first and last views should be equally inset from their superview.
@return An array of constraints added.
*/
- (__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
- (PL__NSArray_of(NSLayoutConstraint *) *)autoDistributeViewsAlongAxis:(ALAxis)axis
alignedTo:(ALAttribute)alignment
withFixedSize:(CGFloat)size
insetSpacing:(BOOL)shouldSpaceInsets
@@ -381,9 +381,9 @@
switch (axis) {
case ALAxisHorizontal:
case ALAxisBaseline: // same value as ALAxisLastBaseline
#if __PureLayout_MinBaseSDK_iOS_8_0
#if PL__PureLayout_MinBaseSDK_iOS_8_0
case ALAxisFirstBaseline:
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 */
fixedDimension = ALDimensionWidth;
attribute = NSLayoutAttributeCenterX;
break;
@@ -408,7 +408,7 @@
BOOL shouldFlipOrder = isRightToLeftLayout && (axis != ALAxisVertical); // imitate the effect of leading/trailing when distributing horizontally
__NSMutableArray_of(NSLayoutConstraint *) *constraints = [NSMutableArray new];
__NSArray_of(ALView *) *views = [self al_copyViewsOnly];
PL__NSArray_of(ALView *) *views = [self al_copyViewsOnly];
NSUInteger numberOfViews = [views count];
ALView *commonSuperview = [views al_commonSuperviewOfViews];
ALView *previousView = nil;
@@ -491,7 +491,7 @@
@return A new array containing only the views that are in this array.
*/
- (__NSArray_of(ALView *) *)al_copyViewsOnly
- (PL__NSArray_of(ALView *) *)al_copyViewsOnly
{
__NSMutableArray_of(ALView *) *viewsOnlyArray = [NSMutableArray arrayWithCapacity:[self count]];
for (id object in self) {
@@ -28,7 +28,7 @@
#import "PureLayoutDefines.h"
__PL_ASSUME_NONNULL_BEGIN
PL__ASSUME_NONNULL_BEGIN
#pragma mark NSLayoutConstraint+PureLayout
@@ -43,32 +43,32 @@ __PL_ASSUME_NONNULL_BEGIN
/** Creates all of the constraints in the block, then installs (activates) them all at once.
All constraints created from calls to the PureLayout API in the block are returned in a single array.
This may be more efficient than installing (activating) each constraint one-by-one. */
+ (__NSArray_of(NSLayoutConstraint *) *)autoCreateAndInstallConstraints:(ALConstraintsBlock)block;
+ (PL__NSArray_of(NSLayoutConstraint *) *)autoCreateAndInstallConstraints:(__attribute__((noescape)) ALConstraintsBlock)block;
/** Creates all of the constraints in the block but prevents them from being automatically installed (activated).
All constraints created from calls to the PureLayout API in the block are returned in a single array. */
+ (__NSArray_of(NSLayoutConstraint *) *)autoCreateConstraintsWithoutInstalling:(ALConstraintsBlock)block;
+ (PL__NSArray_of(NSLayoutConstraint *) *)autoCreateConstraintsWithoutInstalling:(__attribute__((noescape)) ALConstraintsBlock)block;
#pragma mark Set Priority For Constraints
/** Sets the constraint priority to the given value for all constraints created using the PureLayout API within the given constraints block.
NOTE: This method will have no effect (and will NOT set the priority) on constraints created or added without using the PureLayout API! */
+ (void)autoSetPriority:(ALLayoutPriority)priority forConstraints:(ALConstraintsBlock)block;
+ (void)autoSetPriority:(ALLayoutPriority)priority forConstraints:(__attribute__((noescape)) ALConstraintsBlock)block;
#pragma mark Identify Constraints
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
#if PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10
/** Sets the identifier for all constraints created using the PureLayout API within the given constraints block.
NOTE: This method will have no effect (and will NOT set the identifier) on constraints created or added without using the PureLayout API! */
+ (void)autoSetIdentifier:(NSString *)identifier forConstraints:(ALConstraintsBlock)block;
+ (void)autoSetIdentifier:(NSString *)identifier forConstraints:(__attribute__((noescape)) ALConstraintsBlock)block;
/** Sets the string as the identifier for this constraint. Available in iOS 7.0 and OS X 10.9 and later. */
- (instancetype)autoIdentify:(NSString *)identifier;
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10 */
#pragma mark Install & Remove Constraints
@@ -81,4 +81,4 @@ __PL_ASSUME_NONNULL_BEGIN
@end
__PL_ASSUME_NONNULL_END
PL__ASSUME_NONNULL_END
@@ -95,7 +95,7 @@ static BOOL _al_isInstallingCreatedConstraints = NO;
@param block A block of method calls to the PureLayout API that create constraints.
@return An array of the constraints that were created from calls to the PureLayout API inside the block.
*/
+ (__NSArray_of(NSLayoutConstraint *) *)autoCreateAndInstallConstraints:(ALConstraintsBlock)block
+ (PL__NSArray_of(NSLayoutConstraint *) *)autoCreateAndInstallConstraints:(__attribute__((noescape)) ALConstraintsBlock)block
{
NSArray *createdConstraints = [self autoCreateConstraintsWithoutInstalling:block];
_al_isInstallingCreatedConstraints = YES;
@@ -114,7 +114,7 @@ static BOOL _al_isInstallingCreatedConstraints = NO;
@param block A block of method calls to the PureLayout API that create constraints.
@return An array of the constraints that were created from calls to the PureLayout API inside the block.
*/
+ (__NSArray_of(NSLayoutConstraint *) *)autoCreateConstraintsWithoutInstalling:(ALConstraintsBlock)block
+ (PL__NSArray_of(NSLayoutConstraint *) *)autoCreateConstraintsWithoutInstalling:(__attribute__((noescape)) ALConstraintsBlock)block
{
NSAssert(block, @"The constraints block cannot be nil.");
NSArray *createdConstraints = nil;
@@ -184,7 +184,7 @@ static __NSMutableArray_of(NSNumber *) *_al_globalConstraintPriorities = nil;
@param priority The layout priority to be set on all constraints created in the constraints block.
@param block A block of method calls to the PureLayout API that create and install constraints.
*/
+ (void)autoSetPriority:(ALLayoutPriority)priority forConstraints:(ALConstraintsBlock)block
+ (void)autoSetPriority:(ALLayoutPriority)priority forConstraints:(__attribute__((noescape)) ALConstraintsBlock)block
{
NSAssert(block, @"The constraints block cannot be nil.");
if (block) {
@@ -197,7 +197,7 @@ static __NSMutableArray_of(NSNumber *) *_al_globalConstraintPriorities = nil;
#pragma mark Identify Constraints
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
#if PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10
/**
A global variable that stores a stack of identifier strings to set on constraints.
@@ -244,7 +244,7 @@ static __NSMutableArray_of(NSString *) *_al_globalConstraintIdentifiers = nil;
@param identifier A string used to identify all constraints created in the constraints block.
@param block A block of method calls to the PureLayout API that create and install constraints.
*/
+ (void)autoSetIdentifier:(NSString *)identifier forConstraints:(ALConstraintsBlock)block
+ (void)autoSetIdentifier:(NSString *)identifier forConstraints:(__attribute__((noescape)) ALConstraintsBlock)block
{
NSAssert(block, @"The constraints block cannot be nil.");
NSAssert(identifier, @"The identifier string cannot be nil.");
@@ -275,7 +275,7 @@ static __NSMutableArray_of(NSString *) *_al_globalConstraintIdentifiers = nil;
return self;
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10 */
#pragma mark Install & Remove Constraints
@@ -285,7 +285,7 @@ static __NSMutableArray_of(NSString *) *_al_globalConstraintIdentifiers = nil;
*/
- (void)autoInstall
{
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
#if PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10
if ([self respondsToSelector:@selector(setActive:)]) {
[NSLayoutConstraint al_applyGlobalStateToConstraint:self];
if ([NSLayoutConstraint al_preventAutomaticConstraintInstallation]) {
@@ -295,7 +295,7 @@ static __NSMutableArray_of(NSString *) *_al_globalConstraintIdentifiers = nil;
}
return;
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10 */
NSAssert(self.firstItem || self.secondItem, @"Can't install a constraint with nil firstItem and secondItem.");
if (self.firstItem) {
@@ -318,12 +318,12 @@ static __NSMutableArray_of(NSString *) *_al_globalConstraintIdentifiers = nil;
*/
- (void)autoRemove
{
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
#if PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10
if ([self respondsToSelector:@selector(setActive:)]) {
self.active = NO;
return;
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10 */
if (self.secondItem) {
ALView *commonSuperview = [self.firstItem al_commonSuperviewWithView:self.secondItem];
@@ -356,12 +356,12 @@ static __NSMutableArray_of(NSString *) *_al_globalConstraintIdentifiers = nil;
if ([NSLayoutConstraint al_isExecutingPriorityConstraintsBlock]) {
constraint.priority = [NSLayoutConstraint al_currentGlobalConstraintPriority];
}
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
#if PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10
NSString *globalConstraintIdentifier = [NSLayoutConstraint al_currentGlobalConstraintIdentifier];
if (globalConstraintIdentifier) {
[constraint autoIdentify:globalConstraintIdentifier];
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10 */
}
/**
@@ -406,44 +406,44 @@ static __NSMutableArray_of(NSString *) *_al_globalConstraintIdentifiers = nil;
case ALAxisBaseline: // same value as ALAxisLastBaseline
layoutAttribute = NSLayoutAttributeBaseline;
break;
#if __PureLayout_MinBaseSDK_iOS_8_0
#if PL__PureLayout_MinBaseSDK_iOS_8_0
case ALAxisFirstBaseline:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALAxisFirstBaseline is only supported on iOS 8.0 or higher.");
NSAssert(PL__PureLayout_MinSysVer_iOS_8_0, @"ALAxisFirstBaseline is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeFirstBaseline;
break;
case ALMarginLeft:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeLeftMargin is only supported on iOS 8.0 or higher.");
NSAssert(PL__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeLeftMargin is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeLeftMargin;
break;
case ALMarginRight:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeRightMargin is only supported on iOS 8.0 or higher.");
NSAssert(PL__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeRightMargin is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeRightMargin;
break;
case ALMarginTop:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeTopMargin is only supported on iOS 8.0 or higher.");
NSAssert(PL__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeTopMargin is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeTopMargin;
break;
case ALMarginBottom:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeBottomMargin is only supported on iOS 8.0 or higher.");
NSAssert(PL__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeBottomMargin is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeBottomMargin;
break;
case ALMarginLeading:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeLeadingMargin is only supported on iOS 8.0 or higher.");
NSAssert(PL__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeLeadingMargin is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeLeadingMargin;
break;
case ALMarginTrailing:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeTrailingMargin is only supported on iOS 8.0 or higher.");
NSAssert(PL__PureLayout_MinSysVer_iOS_8_0, @"ALEdgeTrailingMargin is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeTrailingMargin;
break;
case ALMarginAxisVertical:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALAxisVerticalMargin is only supported on iOS 8.0 or higher.");
NSAssert(PL__PureLayout_MinSysVer_iOS_8_0, @"ALAxisVerticalMargin is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeCenterXWithinMargins;
break;
case ALMarginAxisHorizontal:
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"ALAxisHorizontalMargin is only supported on iOS 8.0 or higher.");
NSAssert(PL__PureLayout_MinSysVer_iOS_8_0, @"ALAxisHorizontalMargin is only supported on iOS 8.0 or higher.");
layoutAttribute = NSLayoutAttributeCenterYWithinMargins;
break;
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 */
default:
NSAssert(nil, @"Not a valid ALAttribute.");
break;
@@ -465,9 +465,9 @@ static __NSMutableArray_of(NSString *) *_al_globalConstraintIdentifiers = nil;
break;
case ALAxisHorizontal:
case ALAxisBaseline: // same value as ALAxisLastBaseline
#if __PureLayout_MinBaseSDK_iOS_8_0
#if PL__PureLayout_MinBaseSDK_iOS_8_0
case ALAxisFirstBaseline:
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 */
constraintAxis = ALLayoutConstraintAxisHorizontal;
break;
default:
@@ -478,7 +478,7 @@ static __NSMutableArray_of(NSString *) *_al_globalConstraintIdentifiers = nil;
return constraintAxis;
}
#if __PureLayout_MinBaseSDK_iOS_8_0
#if PL__PureLayout_MinBaseSDK_iOS_8_0
/**
Returns the corresponding margin for the given edge.
@@ -488,7 +488,7 @@ static __NSMutableArray_of(NSString *) *_al_globalConstraintIdentifiers = nil;
*/
+ (ALMargin)al_marginForEdge:(ALEdge)edge
{
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"Margin attributes are only supported on iOS 8.0 or higher.");
NSAssert(PL__PureLayout_MinSysVer_iOS_8_0, @"Margin attributes are only supported on iOS 8.0 or higher.");
ALMargin margin;
switch (edge) {
case ALEdgeLeft:
@@ -525,7 +525,7 @@ static __NSMutableArray_of(NSString *) *_al_globalConstraintIdentifiers = nil;
*/
+ (ALMarginAxis)al_marginAxisForAxis:(ALAxis)axis
{
NSAssert(__PureLayout_MinSysVer_iOS_8_0, @"Margin attributes are only supported on iOS 8.0 or higher.");
NSAssert(PL__PureLayout_MinSysVer_iOS_8_0, @"Margin attributes are only supported on iOS 8.0 or higher.");
ALMarginAxis marginAxis;
switch (axis) {
case ALAxisVertical:
@@ -547,6 +547,6 @@ static __NSMutableArray_of(NSString *) *_al_globalConstraintIdentifiers = nil;
return marginAxis;
}
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 */
@end
@@ -29,9 +29,9 @@
// Using generics with NSMutableArray is so common in the internal implementation of PureLayout that it gets a dedicated preprocessor macro for better readability.
#define __NSMutableArray_of(type) __PL_GENERICS(NSMutableArray, type)
#define __NSMutableArray_of(type) PL__GENERICS(NSMutableArray, type)
__PL_ASSUME_NONNULL_BEGIN
PL__ASSUME_NONNULL_BEGIN
/** A constant that represents the smallest valid positive value for the multiplier of a constraint,
since a value of 0 will cause the second item to be lost in the internal auto layout engine. */
@@ -57,7 +57,7 @@ static const CGFloat kMULTIPLIER_MIN_VALUE = (CGFloat)0.00001; // very small flo
- (ALView *)al_commonSuperviewOfViews;
- (BOOL)al_containsMinimumNumberOfViews:(NSUInteger)minimumNumberOfViews;
- (__NSArray_of(ALView *) *)al_copyViewsOnly;
- (PL__NSArray_of(ALView *) *)al_copyViewsOnly;
@end
@@ -71,17 +71,17 @@ static const CGFloat kMULTIPLIER_MIN_VALUE = (CGFloat)0.00001; // very small flo
+ (__NSMutableArray_of(NSLayoutConstraint *) *)al_currentArrayOfCreatedConstraints;
+ (BOOL)al_isExecutingPriorityConstraintsBlock;
+ (ALLayoutPriority)al_currentGlobalConstraintPriority;
#if __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10
#if PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10
+ (NSString *)al_currentGlobalConstraintIdentifier;
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 || __PureLayout_MinBaseSDK_OSX_10_10 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 || PL__PureLayout_MinBaseSDK_OSX_10_10 */
+ (void)al_applyGlobalStateToConstraint:(NSLayoutConstraint *)constraint;
+ (NSLayoutAttribute)al_layoutAttributeForAttribute:(ALAttribute)attribute;
+ (ALLayoutConstraintAxis)al_constraintAxisForAxis:(ALAxis)axis;
#if __PureLayout_MinBaseSDK_iOS_8_0
#if PL__PureLayout_MinBaseSDK_iOS_8_0
+ (ALMargin)al_marginForEdge:(ALEdge)edge;
+ (ALMarginAxis)al_marginAxisForAxis:(ALAxis)axis;
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 */
@end
__PL_ASSUME_NONNULL_END
PL__ASSUME_NONNULL_END
@@ -31,35 +31,35 @@
#import <Foundation/Foundation.h>
// Define some preprocessor macros to check for a minimum Base SDK. These are used to prevent compile-time errors in older versions of Xcode.
#define __PureLayout_MinBaseSDK_iOS_8_0 (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1)
#define __PureLayout_MinBaseSDK_OSX_10_10 (!TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MAX_ALLOWED > __MAC_10_9)
#define PL__PureLayout_MinBaseSDK_iOS_8_0 (TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1)
#define PL__PureLayout_MinBaseSDK_OSX_10_10 (!TARGET_OS_IPHONE && __MAC_OS_X_VERSION_MAX_ALLOWED > __MAC_10_9)
// Define some preprocessor macros to check for a minimum System Version. These are used to prevent runtime crashes on older versions of iOS/OS X.
#define __PureLayout_MinSysVer_iOS_7_0 (TARGET_OS_IPHONE && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1)
#define __PureLayout_MinSysVer_iOS_8_0 (TARGET_OS_IPHONE && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1)
#define __PureLayout_MinSysVer_OSX_10_9 (!TARGET_OS_IPHONE && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber10_8_4)
#define PL__PureLayout_MinSysVer_iOS_7_0 (TARGET_OS_IPHONE && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_6_1)
#define PL__PureLayout_MinSysVer_iOS_8_0 (TARGET_OS_IPHONE && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1)
#define PL__PureLayout_MinSysVer_OSX_10_9 (!TARGET_OS_IPHONE && floor(NSFoundationVersionNumber) > NSFoundationVersionNumber10_8_4)
// Define some preprocessor macros that allow nullability annotations to be adopted in a backwards-compatible manner.
#if __has_feature(nullability)
# define __PL_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
# define __PL_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
# define PL__ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
# define PL__ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
#else
# define __PL_ASSUME_NONNULL_BEGIN
# define __PL_ASSUME_NONNULL_END
# define PL__ASSUME_NONNULL_BEGIN
# define PL__ASSUME_NONNULL_END
#endif
// Define some preprocessor macros that allow generics to be adopted in a backwards-compatible manner.
#if __has_feature(objc_generics)
# define __PL_GENERICS(class, ...) class<__VA_ARGS__>
# define PL__GENERICS(class, ...) class<__VA_ARGS__>
#else
# define __PL_GENERICS(class, ...) class
# define PL__GENERICS(class, ...) class
#endif
// Using generics with NSArray is so common in PureLayout that it gets a dedicated preprocessor macro for better readability.
#define __NSArray_of(type) __PL_GENERICS(NSArray, type)
#define PL__NSArray_of(type) PL__GENERICS(NSArray, type)
// Define generic AL-prefixed macros for the types/constants/etc that have slight naming variations across iOS and OS X, which allows the same code to be platform-independent.
#if TARGET_OS_IPHONE
#if TARGET_OS_IPHONE || TARGET_OS_TV
# import <UIKit/UIKit.h>
# define ALView UIView
# define ALEdgeInsets UIEdgeInsets
@@ -135,13 +135,13 @@ typedef NS_ENUM(NSInteger, ALAxis) {
ALAxisBaseline = NSLayoutAttributeBaseline,
/** A horizontal line at the baseline of the last line of text in the view. (For views that do not draw text, will be equivalent to ALEdgeBottom.) */
ALAxisLastBaseline = ALAxisBaseline,
#if __PureLayout_MinBaseSDK_iOS_8_0
#if PL__PureLayout_MinBaseSDK_iOS_8_0
/** A horizontal line at the baseline of the first line of text in a view. (For views that do not draw text, will be equivalent to ALEdgeTop.) Available in iOS 8.0 and later. */
ALAxisFirstBaseline = NSLayoutAttributeFirstBaseline
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 */
};
#if __PureLayout_MinBaseSDK_iOS_8_0
#if PL__PureLayout_MinBaseSDK_iOS_8_0
/** Constants that represent layout margins of a view. Available in iOS 8.0 and later. */
typedef NS_ENUM(NSInteger, ALMargin) {
@@ -167,7 +167,7 @@ typedef NS_ENUM(NSInteger, ALMarginAxis) {
ALMarginAxisHorizontal = NSLayoutAttributeCenterYWithinMargins
};
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 */
/** An attribute of a view that can be used in auto layout constraints. These constants are identical to the more specific enum types:
ALEdge, ALAxis, ALDimension, ALMargin, ALMarginAxis. It is safe to cast a more specific enum type to the ALAttribute type. */
@@ -196,7 +196,7 @@ typedef NS_ENUM(NSInteger, ALAttribute) {
ALAttributeBaseline = ALAxisBaseline,
/** A horizontal line at the baseline of the last line of text in the view. (For views that do not draw text, will be equivalent to ALEdgeBottom.) */
ALAttributeLastBaseline = ALAxisLastBaseline,
#if __PureLayout_MinBaseSDK_iOS_8_0
#if PL__PureLayout_MinBaseSDK_iOS_8_0
/** A horizontal line at the baseline of the first line of text in a view. (For views that do not draw text, will be equivalent to ALEdgeTop.) Available in iOS 8.0 and later. */
ALAttributeFirstBaseline = ALAxisFirstBaseline,
/** The left margin of the view, based on the view's layoutMargins left inset. */
@@ -215,7 +215,7 @@ typedef NS_ENUM(NSInteger, ALAttribute) {
ALAttributeMarginAxisVertical = ALMarginAxisVertical,
/** A horizontal line equidistant from the view's top and bottom margins. */
ALAttributeMarginAxisHorizontal = ALMarginAxisHorizontal
#endif /* __PureLayout_MinBaseSDK_iOS_8_0 */
#endif /* PL__PureLayout_MinBaseSDK_iOS_8_0 */
};
/** A block containing method calls to the PureLayout API. Takes no arguments and has no return value. */
+3 -3
View File
@@ -1,5 +1,5 @@
# [![PureLayout](https://github.com/PureLayout/PureLayout/blob/master/Images/PureLayout.png?raw=true)](#)
[![Build Status](http://img.shields.io/travis/PureLayout/PureLayout.svg?style=flat)](https://travis-ci.org/PureLayout/PureLayout) [![Test Coverage](http://img.shields.io/coveralls/PureLayout/PureLayout.svg?style=flat)](https://coveralls.io/r/PureLayout/PureLayout) [![Version](http://img.shields.io/cocoapods/v/PureLayout.svg?style=flat)](http://cocoapods.org/?q=PureLayout) [![Platform](http://img.shields.io/cocoapods/p/PureLayout.svg?style=flat)](http://cocoapods.org/?q=PureLayout) [![License](http://img.shields.io/cocoapods/l/PureLayout.svg?style=flat)](LICENSE)
[![Build Status](http://img.shields.io/travis/PureLayout/PureLayout.svg?style=flat)](https://travis-ci.org/PureLayout/PureLayout) [![Test Coverage](http://img.shields.io/coveralls/PureLayout/PureLayout.svg?style=flat)](https://coveralls.io/r/PureLayout/PureLayout) [![Version](http://img.shields.io/cocoapods/v/PureLayout.svg?style=flat)](http://cocoapods.org/pods/PureLayout) [![Platform](http://img.shields.io/cocoapods/p/PureLayout.svg?style=flat)](http://cocoapods.org/pods/PureLayout) [![License](http://img.shields.io/cocoapods/l/PureLayout.svg?style=flat)](LICENSE)
The ultimate API for iOS & OS X Auto Layout — impressively simple, immensely powerful. PureLayout extends `UIView`/`NSView`, `NSArray`, and `NSLayoutConstraint` with a comprehensive Auto Layout API that is modeled after Apple's own frameworks. PureLayout is a cross-platform Objective-C library that works (and looks!) great in Swift. It is fully backwards-compatible with all versions of iOS and OS X that support Auto Layout.
@@ -100,7 +100,7 @@ Additionally, there is one generic attribute type, `ALAttribute`, which is effec
### [`UIView`/`NSView`](PureLayout/PureLayout/ALView%2BPureLayout.h)
```
- autoSetContent(CompressionResistance|Hugging)PriorityForAxis:
- autoCenterInSuperview(Margins): // Margins variant iOS 8.0+ only
- autoCenterInSuperview(Margins) // Margins variant iOS 8.0+ only
- autoAlignAxisToSuperview(Margin)Axis: // Margin variant iOS 8.0+ only
- autoPinEdgeToSuperview(Edge:|Margin:)(withInset:) // Margin variant iOS 8.0+ only
- autoPinEdgesToSuperview(Edges|Margins)(WithInsets:)(excludingEdge:) // Margins variant iOS 8.0+ only
@@ -192,7 +192,7 @@ There are quite a few different ways to implement Auto Layout. Here is a quick o
* Apple [NSLayoutConstraint SDK API](https://developer.apple.com/library/ios/documentation/AppKit/Reference/NSLayoutConstraint_Class/index.html#//apple_ref/occ/clm/NSLayoutConstraint/constraintWithItem:attribute:relatedBy:toItem:attribute:multiplier:constant:)
* Pros: Raw power
* Cons: Extremely verbose; tedious to write; difficult to read
* Apple [Visual Format Language](https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/VisualFormatLanguage/VisualFormatLanguage.html)
* Apple [Visual Format Language](https://developer.apple.com/library/ios/documentation/UserExperience/Conceptual/AutolayoutPG/VisualFormatLanguage.html)
* Pros: Concise; convenient
* Cons: Doesn't support some use cases; lacks compile-time checking and safety; must learn syntax; hard to debug
* Apple Interface Builder