bryceredd / RFQuiltLayout

A UICollectionViewLayout subclass to put items in a quilting pattern
MIT License
872 stars 130 forks source link

Cell Size based on content? #12

Open thedangler opened 10 years ago

thedangler commented 10 years ago

Hey, I'm just wondering how I should use this for printing labels inside the cells. If I return the label size in the blockSizeForItemAtIndexPath: method it makes the cell way to big because its multiplying it by the blockPixels or something of that nature.

Any ideas?

M

bryceredd commented 10 years ago

So how this works is you define how big a block is, then you specify how many blocks a cell takes up - this is an optimization for speed, and it helps fit all the items together.

Think of the quilt layout like legos: block pixels specifies how big the 1x1 lego unit is, then block size will determine how big the lego piece is in terms of lego units.

You could try setting blockPixels to 1, and returning the exact size of the label in blockSize, but I'm not sure how that will perform!

thedangler commented 10 years ago

Hey. Thanks for the answer. After messing around for a bit using 1x1 seems like it should have worked but it was a little messy looking. I don't know if that is because of the label size not being calculated correctly or something else.  What was happening is the width of the label always seemed to e a bit bigger than the block.  

M

— Sent from Mailbox for iPhone

On Tue, Oct 22, 2013 at 10:46 AM, bryceredd notifications@github.com wrote:

So how this works is you define how big a block is, then you specify how many blocks a cell takes up - this is an optimization for speed, and it helps fit all the items together. Think of the quilt layout like legos: block pixels specifies how big the 1x1 lego unit is, then block size will determine how big the lego piece is in terms of lego units.

You could try setting blockPixels to 1, and returning the exact size of the label in blockSize, but I'm not sure how that will perform!

Reply to this email directly or view it on GitHub: https://github.com/bryceredd/RFQuiltLayout/issues/12#issuecomment-26809248