Skip to content
This repository was archived by the owner on Feb 2, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion AsyncDisplayKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1523,7 +1523,7 @@
058D09B9195D04C000B7D73C /* Frameworks */,
058D09BA195D04C000B7D73C /* Resources */,
3B9D88CDF51B429C8409E4B6 /* Copy Pods Resources */,
1B86F48711505F91D5FEF571 /* Embed Pods Frameworks */,
5ADEA7587189397768F2B36C /* Embed Pods Frameworks */,
);
buildRules = (
);
Expand Down Expand Up @@ -1668,6 +1668,21 @@
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AsyncDisplayKitTests/Pods-AsyncDisplayKitTests-resources.sh\"\n";
showEnvVarsInLog = 0;
};
5ADEA7587189397768F2B36C /* Embed Pods Frameworks */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = "Embed Pods Frameworks";
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-AsyncDisplayKitTests/Pods-AsyncDisplayKitTests-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */

/* Begin PBXSourcesBuildPhase section */
Expand Down
11 changes: 11 additions & 0 deletions AsyncDisplayKit/ASButtonNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,17 @@ typedef enum : NSUInteger {
*/
@property (nonatomic, assign) BOOL laysOutHorizontally;

/** Horizontally align content (text or image).
Defaults to ASAlignmentMiddle.
*/
@property (nonatomic, assign) ASHorizontalAlignment contentHorizontalAlignment;

/** Vertically align content (text or image).
Defaults to ASAlignmentCenter.
*/
@property (nonatomic, assign) ASVerticalAlignment contentVerticalAlignment;


- (NSAttributedString *)attributedTitleForState:(ASButtonState)state;
- (void)setAttributedTitle:(NSAttributedString *)title forState:(ASButtonState)state;

Expand Down
7 changes: 5 additions & 2 deletions AsyncDisplayKit/ASButtonNode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ - (instancetype)init
_titleNode = [[ASTextNode alloc] init];
_imageNode = [[ASImageNode alloc] init];

_contentHorizontalAlignment = ASAlignmentMiddle;
_contentVerticalAlignment = ASAlignmentCenter;

[self addSubnode:_titleNode];
[self addSubnode:_imageNode];

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

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