Skip to content

Instantly share code, notes, and snippets.

@bdalziel
Last active July 27, 2016 22:14
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 bdalziel/90cc6f7879c69f003fde89c14e1e5c91 to your computer and use it in GitHub Desktop.
Save bdalziel/90cc6f7879c69f003fde89c14e1e5c91 to your computer and use it in GitHub Desktop.
// https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITraitEnvironment_Ref/#//apple_ref/occ/intfm/UITraitEnvironment/traitCollectionDidChange:
-(void)traitCollectionDidChange:(UITraitCollection *)previousTraitCollection {
[super traitCollectionDidChange:previousTraitCollection];
[self handleMargins:self.traitCollection];
}
- (void)renderHeatIntoCell:(ASPFantasyPickemGame *)fantasyGame athleteId:(NSString *)athleteId eventId:(NSString *)eventId roundNumber:(NSString *)roundNumber rosterSlot:(NSString *)rosterSlot traitCollection:(UITraitCollection *)contextTraitCollection
{
// Cell setup/rendering
[self handleMargins:contextTraitCollection];
}
- (void)handleMargins:(UITraitCollection *)traitCollection {
CGFloat tinyMargin = [ASPSpacingUtil getSpacing:ASPSpacingSizeTiny traitCollection:self.traitCollection];
CGFloat smallMargin = [ASPSpacingUtil getSpacing:ASPSpacingSizeSmall traitCollection:self.traitCollection];
CGFloat topMargin = smallMargin - [ASPFontUtil topUIBaselineAdjustment:ASPUITextElementFantasyAthleteProfileHeatSummary traitCollection:traitCollection];
CGFloat bottomMargin = smallMargin - [ASPFontUtil bottomUIBaselineAdjustment:ASPUITextElementFantasyAthleteProfileHeatPoints traitCollection:traitCollection];
self.layoutMargins = UIEdgeInsetsZero;
self.contentView.layoutMargins = UIEdgeInsetsMake(0, 0, tinyMargin, 0);
self.contentCard.layoutMargins = UIEdgeInsetsMake(topMargin, smallMargin, bottomMargin, smallMargin);
self.constraintHeatPointsTop.constant = tinyMargin - [ASPFontUtil bottomUIBaselineAdjustment:ASPUITextElementFantasyAthleteProfileHeatSummary traitCollection:traitCollection] - [ASPFontUtil topUIBaselineAdjustment:ASPUITextElementFantasyAthleteProfileHeatPoints traitCollection:traitCollection];
[self layoutMarginsDidChange];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment