Skip to content

Instantly share code, notes, and snippets.

@bdalziel
Last active October 22, 2016 16:36
Show Gist options
  • Save bdalziel/7cf19a0dc6048c759382d1a37ce9ab1c to your computer and use it in GitHub Desktop.
Save bdalziel/7cf19a0dc6048c759382d1a37ce9ab1c to your computer and use it in GitHub Desktop.
- (void)handleMargins:(UITraitCollection *)contextTraitCollection {
// 1. Get hold of a bunch of sizes based on the traits of the context we're rendering in
CGFloat deviceScale = [UIScreen mainScreen].scale;
CGFloat smallMargin = [ASPSpacingUtil getSpacing:ASPSpacingSizeSmall traitCollection:contextTraitCollection];
CGFloat gutterWidth = [ASPSpacingUtil getGutterWidth:contextTraitCollection];
CGFloat horizontalMargin = [ASPSpacingUtil getLeftAndRightCellMargins:contextTraitCollection];
// 2. Setup containing margins
// Zero out cell margins, and set horizontal indent on contentview - important for the transition from full bleed to gutters (regular class sizes such as iPad portrait)
// Small margin bottom represents between cell padding.
self.layoutMargins = UIEdgeInsetsZero;
self.contentView.layoutMargins = UIEdgeInsetsMake(0, horizontalMargin, smallMargin, horizontalMargin);
// 3. Set card inner margins to position labels
self.contentCard.layoutMargins = UIEdgeInsetsMake(smallMargin, gutterWidth, smallMargin, gutterWidth);
// Rest of implementation to follow...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment