-
Notifications
You must be signed in to change notification settings - Fork 2.2k
ASButtonNode content alignement properties #963
ASButtonNode content alignement properties #963
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla - and if you have received this in error or have any questions, please drop us a line at cla@fb.com. Thanks! |
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
AsyncDisplayKit/ASButtonNode.mm
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@1nput0utput can you set _contentHorizontalAlignment, and _contentVerticalAlignment, to the default values in the -init method for the button? (use the ivars, not the property for efficiency). Then here, set the stack properties directly to the ivar values without checking them. Nothing guarantees that the enum values won't be zero anyway, so I'm not sure it is ideal to use the ternary operator to check if they have been set to non-default values.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@appleguy I'll make the changes. It'll be much legible.
Thanks for thinking about improvements to ASButtonNode! @rcancro, @nguyenhuy, @Adlai-Holler - any ideas on a different way to do this with the current layout system, or does this seem like the best way? It does minimize exposing different properties of the stack, and we can't really expose the stack layout spec directly anyway without holding a reference to it, which is not allowed with the current design. |
ad3d9bc
to
108ce6d
Compare
@1nput0utput thank you! This is nice and clean, simple but useful! |
…nment [ASButtonNode] Content alignement properties for image and text.
@appleguy This small change allows content alignment like in the UIButton. The reason I had initially implemented this was to align 4 ASButtonNodes with flexBasis set with ASRelativeDimension(type: .Percent, value: 0.25). I simply wanted the ability to align ASButtonNode's content to make my whole view look good. I will create another PR for other behaviours I have in my app.