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

CardView doesn't center pure textural content #355

Closed
danielsaidi opened this issue Oct 16, 2019 · 8 comments
Closed

CardView doesn't center pure textural content #355

danielsaidi opened this issue Oct 16, 2019 · 8 comments

Comments

@danielsaidi
Copy link

We use CardView.xib to display a pure text message, without an icon, title or button. We set the body label's text alignment to center, since we want the text centered in the card.

The problem is that the content is only centered when the text is long enough to wrap over two lines. We can fix this by opening CardView.xib and set Alignment to Fill for the vertical, innermost stack view.

We considered a couple of ways this could be done, but ended up in that it would be nice to have a "pure text card" view, for which the content is centered. We will add such a xib to our project now, but it would be nice if the library could include such a xib as well.

@wtmoose
Copy link
Member

wtmoose commented Oct 16, 2019

The nibs are intended to supply basic form factors only. Supporting all of the permutations of form factor and content wouldn't be practical IMO. The nibs are provided so you can copy them into your project and easily modify them to suit your specific needs.

In any case, I'm fine with changing the alignment to Fill. Did you foresee an issue with that?

@danielsaidi
Copy link
Author

Hi @wtmoose !

Yeah, you are right - the docs emphazise that you should copy the xibs and use them as templates. However, I found it strange (and a little wrong hehe) that the text is left-aligned if it's short, but centered if it's longer and spans over several lines.

If fill solves the problem, that'd be great. I haven't tried the combo icon + text + fill + button, so I'm not sure if it causes any other side-effects.

@wtmoose
Copy link
Member

wtmoose commented Oct 27, 2019

I put a fix for this on the head of master if you want to try it. Will release soon.

@danielsaidi
Copy link
Author

Sorry for the slow reply, we’ve been busy at work. Great, I’ll try it and see if it works :)

@dasoga
Copy link

dasoga commented Feb 7, 2020

Hi @wtmoose i tried to center the body text (not using any other element) and it worked if I copy the framework manually, any plans to release this in cocoapods?

thanks!

@bukerapp
Copy link

Same question as above, thank you.

@kientux
Copy link

kientux commented Jul 6, 2020

Same issue, still waiting for new release which fixes this. Until then, if you don't want to copy and edit the xib, just use this (a little ugly) fix:

if let stackView = view.titleLabel?.superview as? UIStackView {
    stackView.alignment = .fill
}

@wtmoose
Copy link
Member

wtmoose commented Jul 9, 2020

Included in 8.0.0 release

@wtmoose wtmoose closed this as completed Jul 9, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants