Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question - Alignment inside a stack layout component #70

Closed
avnerbarr opened this issue Apr 7, 2015 · 2 comments
Closed

Question - Alignment inside a stack layout component #70

avnerbarr opened this issue Apr 7, 2015 · 2 comments
Labels

Comments

@avnerbarr
Copy link
Contributor

Component in a collection view cell - I want to align a label on the left side and an image on the right side:

--------------------------------------------------------
--- Label_text------------------------ image----
-------------------------------------------------------
--------------------------------------------------------

I believe I need to use the stack layout component but I'm not sure what the flags should be:
+(instancetype)newWithModel:(ItemModel *)model {
CKStackLayoutComponent *stack = [CKStackLayoutComponent newWithView:{
[UIView class],
{
{@selector(setBackgroundColor:),[UIColor redColor]} // want to see that the container is being streched
}
} size:{} style:{
.alignItems = CKStackLayoutAlignItemsStretch,
.direction = CKStackLayoutDirectionHorizontal,
}children:{
{
.component = [CKLabelComponent newWithLabelAttributes:{
.string = @"Label",
.color = [UIColor whiteColor]
}viewAttributes:{}]
},
{
.component = [CKImageComponent newWithImage:image],
.alignSelf = CKStackLayoutAlignSelfEnd // shouldn't this align it to the end of the box?
}
}];
return [super newWithComponent:stack];
}

@adamjernst
Copy link
Contributor

Not quite. In flexbox, align-items and align-self apply to the cross axis (opposite of the flex/stack axis). So in this case, AlignSelfEnd means "align to the end, i.e. bottom, in the vertical dimension."

Your question is actually exactly the same as #62. You're running into a shortcoming: what you really want is justify-content: space-between; but we don't support it yet. See #62 for a workaround, and #63 tracks fixing the shortcoming.

@avnerbarr
Copy link
Contributor Author

Great. Got it to work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants