Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.

Commit c020dcf

Browse files
committed
Merge pull request #963 from 1nput0utput/ASButtonNodeExposeContentAignment
[ASButtonNode] Content alignement properties for image and text.
2 parents d7492b3 + 108ce6d commit c020dcf

3 files changed

Lines changed: 32 additions & 3 deletions

File tree

AsyncDisplayKit.xcodeproj/project.pbxproj

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1523,7 +1523,7 @@
15231523
058D09B9195D04C000B7D73C /* Frameworks */,
15241524
058D09BA195D04C000B7D73C /* Resources */,
15251525
3B9D88CDF51B429C8409E4B6 /* Copy Pods Resources */,
1526-
1B86F48711505F91D5FEF571 /* Embed Pods Frameworks */,
1526+
5ADEA7587189397768F2B36C /* Embed Pods Frameworks */,
15271527
);
15281528
buildRules = (
15291529
);
@@ -1668,6 +1668,21 @@
16681668
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AsyncDisplayKitTests/Pods-AsyncDisplayKitTests-resources.sh\"\n";
16691669
showEnvVarsInLog = 0;
16701670
};
1671+
5ADEA7587189397768F2B36C /* Embed Pods Frameworks */ = {
1672+
isa = PBXShellScriptBuildPhase;
1673+
buildActionMask = 2147483647;
1674+
files = (
1675+
);
1676+
inputPaths = (
1677+
);
1678+
name = "Embed Pods Frameworks";
1679+
outputPaths = (
1680+
);
1681+
runOnlyForDeploymentPostprocessing = 0;
1682+
shellPath = /bin/sh;
1683+
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AsyncDisplayKitTests/Pods-AsyncDisplayKitTests-frameworks.sh\"\n";
1684+
showEnvVarsInLog = 0;
1685+
};
16711686
/* End PBXShellScriptBuildPhase section */
16721687

16731688
/* Begin PBXSourcesBuildPhase section */

AsyncDisplayKit/ASButtonNode.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,17 @@ typedef enum : NSUInteger {
3131
*/
3232
@property (nonatomic, assign) BOOL laysOutHorizontally;
3333

34+
/** Horizontally align content (text or image).
35+
Defaults to ASAlignmentMiddle.
36+
*/
37+
@property (nonatomic, assign) ASHorizontalAlignment contentHorizontalAlignment;
38+
39+
/** Vertically align content (text or image).
40+
Defaults to ASAlignmentCenter.
41+
*/
42+
@property (nonatomic, assign) ASVerticalAlignment contentVerticalAlignment;
43+
44+
3445
- (NSAttributedString *)attributedTitleForState:(ASButtonState)state;
3546
- (void)setAttributedTitle:(NSAttributedString *)title forState:(ASButtonState)state;
3647

AsyncDisplayKit/ASButtonNode.mm

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ - (instancetype)init
3939
_titleNode = [[ASTextNode alloc] init];
4040
_imageNode = [[ASImageNode alloc] init];
4141

42+
_contentHorizontalAlignment = ASAlignmentMiddle;
43+
_contentVerticalAlignment = ASAlignmentCenter;
44+
4245
[self addSubnode:_titleNode];
4346
[self addSubnode:_imageNode];
4447

@@ -195,8 +198,8 @@ - (ASLayoutSpec *)layoutSpecThatFits:(ASSizeRange)constrainedSize
195198
ASStackLayoutSpec *stack = [[ASStackLayoutSpec alloc] init];
196199
stack.direction = self.laysOutHorizontally ? ASStackLayoutDirectionHorizontal : ASStackLayoutDirectionVertical;
197200
stack.spacing = self.contentSpacing;
198-
stack.justifyContent = ASStackLayoutJustifyContentCenter;
199-
stack.alignItems = ASStackLayoutAlignItemsCenter;
201+
stack.horizontalAlignment = _contentHorizontalAlignment;
202+
stack.verticalAlignment = _contentVerticalAlignment;
200203

201204
NSMutableArray *children = [[NSMutableArray alloc] initWithCapacity:2];
202205
if (self.imageNode.image) {

0 commit comments

Comments
 (0)