Material: Help Wanted: Align CardView center vertically to superview

Created on 26 Apr 2016  路  7Comments  路  Source: CosmicMind/Material

using MaterialLayout how can I make a card view center vertically to parent view?

All alignToParent... methods mess with the card view size.
Am I missing something?
You have mentioned in #104 that you are making an alert view, but I can't find it.

help wanted

Most helpful comment

@mohpor You are wonderful. Let me get though today, and release the new docs style and work, and that will set the example I would like to have in place going forward. I also think we should put a roadmap together as a community and really take Material to the next level. I am dedicating May to making Material the iOS standard for Material Design.

All 7 comments

I think a lot of people will benefit from this, so I will make it today with the updates I am making. I am working on the TextField, SideNav, Pulse, and AlertView to release today with documentation. I will leave this issue up until later today when I release the latest updates.

Looks like you're having too much on your plate @danieldahan
I'm always ready to help. I've actually dedicated a certain amount of time from my workday to help you improve this wonderful library. I mean, you can just ask me. I'm not sure if I am even that helpful, but I can handle a few things.

@mohpor You are wonderful. Let me get though today, and release the new docs style and work, and that will set the example I would like to have in place going forward. I also think we should put a roadmap together as a community and really take Material to the next level. I am dedicating May to making Material the iOS standard for Material Design.

I mean, it is already the de facto standard for iOS!

Sounds good to me.

Well then let's solidify that position :)

Any news?

Here is how you make a card view centered vertically:

        cardView.translatesAutoresizingMaskIntoConstraints = false
        parent.addSubview(cardView)
        MaterialLayout.alignToParentHorizontally(parent, child: cardView, left: 12.0, right: 12.0)
        layoutIfNeeded()
        let top = (view.bounds.height - cardView.height) / 2.0
        MaterialLayout.alignFromTop(view, child: cardView, top: top)

It's a simple patch for now, there will be an AlertView soon. that should solve many other problems as well.

Credits to @danieldahan!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

craigpearce5 picture craigpearce5  路  14Comments

ariedoelman picture ariedoelman  路  34Comments

kylebrowning picture kylebrowning  路  15Comments

ijameelkhan picture ijameelkhan  路  23Comments

MacMeDan picture MacMeDan  路  28Comments