Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Created June 5, 2013 09:34
Show Gist options
  • Save odrobnik/5712761 to your computer and use it in GitHub Desktop.
Save odrobnik/5712761 to your computer and use it in GitHub Desktop.
Which to prefer?
- (CGSize)sizeThatFits:(CGSize)size
{
CGSize neededSize = [self intrinsicContentSize]; // creates layout frame if necessary
if (neededSize.width>=0 && neededSize.height>=0)
{
return neededSize;
}
// 1
return CGSizeMake(_edgeInsets.left + _edgeInsets.right, _edgeInsets.bottom + _edgeInsets.top);
// 2
return CGRectStandardize(UIEdgeInsetsInsetRect(CGRectZero, _edgeInsets)).size;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment