Skip to content

Instantly share code, notes, and snippets.

@Me1000
Created September 5, 2012 04:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Me1000/3630322 to your computer and use it in GitHub Desktop.
Save Me1000/3630322 to your computer and use it in GitHub Desktop.
@implementation VerticalLayoutView : CPView
{
double gapBetweenViews;
}
- (void)setGapBetweenViews:(double)aGap
{
gapBetweenViews = aGap;
}
- (double)gapBetweenViews
{
return gapBetweenViews;
}
- (void)layoutSubviews
{
[super layoutSubviews];
var subviews = [self subviews],
currentY = 0;
for (var i = 0, c = [subviews count]; i < c; i++)
{
var subview = [subviews objectAtIndex:i];
CGRect currentFrame = [subview frame];
var viewHeight = CGRectGetHeight(currentFrame);
[subview setFrame:CGRectMake(0, currentY, CGRectGetWidth(currentFrame), viewHeight];
currentY += viewHeight + [self gapBetweenViews];
}
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment