Skip to content

Instantly share code, notes, and snippets.

@Nub
Created October 7, 2011 08:31
Show Gist options
  • Select an option

  • Save Nub/1269774 to your computer and use it in GitHub Desktop.

Select an option

Save Nub/1269774 to your computer and use it in GitHub Desktop.
NSInteger rows = floorf(self.frame.size.height / (kPostSquareSize + (kPostSquarePadding * 2)));
NSInteger i = 0;
for (CALayer *layer in parentLayer.sublayers) {
CGFloat x = ((i - (i%rows))/rows) * (kPostSquareSize + kPostSquarePadding);
CGFloat y = (i % rows) * (kPostSquareSize + kPostSquarePadding);
CGRect newFrame = CGRectMake(x, y, kPostSquareSize, kPostSquareSize);
layer.frame = newFrame;
i ++;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment