Skip to content

Instantly share code, notes, and snippets.

@bartjacobs
Created June 23, 2015 11:48
Show Gist options
  • Save bartjacobs/f517767dcca8b1899683 to your computer and use it in GitHub Desktop.
Save bartjacobs/f517767dcca8b1899683 to your computer and use it in GitHub Desktop.
layoutSubviews
- (void)layoutSubviews {
[super layoutSubviews];
// Helpers
CGRect bounds = self.contentView.bounds;
// Update Frames
CGRect frameTextLabel = self.textLabel.frame;
CGRect frameDetailTextLabel = self.detailTextLabel.frame;
CGRect frameActivityIndicatorView = self.activityIndicatorView.frame;
frameTextLabel.origin.y = 0.0;
frameTextLabel.origin.x = kTextLabelMarginLeft;
frameTextLabel.size.height = CGRectGetHeight(bounds);
frameTextLabel.size.width = (CGRectGetWidth(bounds) - kTextLabelMarginLeft - kTextLabelMarginRight);
[self.textLabel setFrame:frameTextLabel];
frameDetailTextLabel.origin.y = 0.0;
frameDetailTextLabel.origin.x = kDetailTextLabelMarginRight;
frameDetailTextLabel.size.height = CGRectGetHeight(bounds);
frameDetailTextLabel.size.width = (CGRectGetWidth(bounds) - kDetailTextLabelMarginLeft - kDetailTextLabelMarginRight);
[self.detailTextLabel setFrame:frameDetailTextLabel];
frameActivityIndicatorView.origin.y = ceilf(CGRectGetMidY(bounds) - (CGRectGetHeight(frameActivityIndicatorView) / 2.0));
frameActivityIndicatorView.origin.x = CGRectGetWidth(bounds) - CGRectGetWidth(frameActivityIndicatorView) - kActivityIndicatorViewMarginRight;
[self.activityIndicatorView setFrame:frameActivityIndicatorView];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment