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

ESFlowLayoutView.m #1

Open
nasawz opened this issue Dec 29, 2011 · 0 comments
Open

ESFlowLayoutView.m #1

nasawz opened this issue Dec 29, 2011 · 0 comments

Comments

@nasawz
Copy link

nasawz commented Dec 29, 2011

//Orders in rows. Could be improved to save initial widths for items that are too wide to fit a row.

  • (void)layoutSubviews
    {
    double rowY = padding;
    double maxHeight = 0.0;
    double curX = padding;
    int itemsInRow = 0;

    for(UIView *v in self.subviews)
    {
    //start a new row if needed. If the first item is too wide, present it regardless.
    if(itemsInRow>0 && curX+v.width > self.width)
    {
    rowY = maxHeight + padding;
    //maxHeight = 0.0;
    curX = padding;
    itemsInRow = 0;
    }

    v.y = rowY;
    v.x = curX;
    curX += v.width + padding;
    maxHeight = MAX(maxHeight, (v.height + v.y));
    itemsInRow++;
    

    }
    self.height = rowY + maxHeight + padding;
    }

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

No branches or pull requests

1 participant