cwRichardKim / RKCardView

Beautiful Twitter / Facebook style cards
MIT License
820 stars 74 forks source link

updated to use constraints for better layout on universal devices #6

Open waterskier2007 opened 9 years ago

waterskier2007 commented 9 years ago

fix for issue #5

cwRichardKim commented 9 years ago

do you mind explaining the code a little bit? Is there a reason why you removed the corner radius and shadow path?

waterskier2007 commented 9 years ago

Ah sorry. That was for a project I was doing. You could change the corner and shadow path back.

Basically, when the view was setup from initWithCoder, if you are using a universal storyboard, the frame size is something like 480 x 600, so all of the sizes are wrong. It looks fine on an iPhone but if you move to an iPad with the same universal storyboard, the items are too small to fill the screen.

cwRichardKim commented 9 years ago

ok cool, I'm not very familiar with storyboard (I build everything programmatically). I'm just going to add a few comments to the code so I can better understand this

waterskier2007 commented 9 years ago

No problem. You don't have to merge it if you don't want to. But just to check out what I am talking about, if you create a universal project for iOS 8.0 or greater, you can use a universal storyboard for iPads and iPhone. Try adding an RKCardView as the entire view on a view controller and then run it on both an iPhone and an iPad. You should see that with the code based layout it doesn't fit the iPad but it does with my updated code. It's still all code and doesn't require any additional work in a storyboard, just plop it into a storyboard.

cwRichardKim commented 9 years ago

Yea I’m more concerned about how it’s going to affect programmatic builds (which is the majority of use cases). I’ll spend some time this weekend playing with it. Thanks for putting in the time though!

Richard Kim (Choong-Won)

On Wednesday, February 18, 2015 at 9:49 AM, waterskier2007 wrote:

No problem. You don't have to merge it if you don't want to. But just to check out what I am talking about, if you create a universal project for iOS 8.0 or greater, you can use a universal storyboard for iPads and iPhone. Try adding an RKCardView as the entire view on a view controller and then run it on both an iPhone and an iPad. You should see that with the code based layout it doesn't fit the iPad but it does with my updated code. It's still all code and doesn't require any additional work in a storyboard, just plop it into a storyboard.

— Reply to this email directly or view it on GitHub (https://github.com/cwRichardKim/RKCardView/pull/6#issuecomment-74875495).

waterskier2007 commented 9 years ago

It doesn't change programmatic builds at all. Check it out. Cheers!

waterskier2007 commented 9 years ago

It was personal aesthetic. Sorry, I thought i changed all of the values back to their originals. I copied over some stuff from my own project.

Also, you have to setTranslatesAutoresizingMaskIntoConstraints:NO]; on every view that you want to add constraints too

Basically, all this code is doing is using constraints to layout the views instead of hardcoding the frames, so that the views will scale with the screen size