, shelfView ( , UIScrollView), . x origin FSShelf *shelf = [[FSShelf alloc] initWithFrame:CGRectMake(0, index * [FSConstants getShelfVerticalDistance], 0, 0)];, , - ( ), x, subview, - x! , , . , , - . , , . - ?
, : shelfView - . , , , , , .
. , , . , Shelb ( , , , ), , , . , , - [self.view setNeedsLayout];, viewDidLayoutSubviews . - :
- (void)viewDidLayoutSubviews {
const CGRect rootViewBounds = self.view.bounds;
shelfView.frame = rootViewBounds;
const CGFloat kHorizontalMargin = [FSConstants getShelveMargin];
const CGFloat kVerticalDistancePerShelf = [FSConstants getShelfVerticalDistance];
const CGFloat kShelfHeight = 30.0;
const NSUInteger shelvesCount = [shelves count];
for (NSUInteger j = 0; j < shelvesCount; j++) {
UIView *shelf = [shelves objectAtIndex:j];
shelf.frame = CGRectMake(kHorizontalMargin,
j * kVerticalDistancePerShelf,
CGRectGetWidth(rootViewBounds) - 2.0 * kHorizontalMargin,
kShelfHeight);
}
shelfView.contentSize = CGSizeMake(CGRectGetWidth(rootViewBounds), (shelvesCount - 1) * kVerticalDistancePerShelf + kShelfHeight);
}