PaoloCuscela / Cards

Awesome iOS 11 appstore cards in swift 5.
MIT License
4.2k stars 274 forks source link

Centering Title Label #54

Closed asikand-view closed 6 years ago

asikand-view commented 6 years ago

So I'm trying to center the Title Label for a particular view I'm building. I managed to center the Category Label by setting

categoryLbl.textAlignment = .center

But when I try to do the same thing for titleLbl, nothing happens. This is where I am right now:

screen shot 2018-06-11 at 12 47 03 pm

asikand-view commented 6 years ago

I've tried playing around with the

categoryLbl.frame and titleLbl.frame

but I can't seem to find a correct formula for setting the x, y, and width

PaoloCuscela commented 6 years ago

If you want to create a custom card you can inherit 'Card' class and use the layout method to lay your UI objects inside. You can use 'backgroundIV.bounds as a rect reference. That method is called during the animations after changing the backgroundIV frame, so the size of your UIViews should be dependent on it.