Skip to content

Instantly share code, notes, and snippets.

@pier-oliviert
Created January 10, 2011 12:03
Show Gist options
  • Save pier-oliviert/772686 to your computer and use it in GitHub Desktop.
Save pier-oliviert/772686 to your computer and use it in GitHub Desktop.
- (CGSize)sizeConstrainedInRect:(CGRect)rect {
CGSize size = CGSizeZero;
UIGraphicsBeginImageContextWithOptions(rect.size, YES, self.layer.contentsScale);
CGContextRef ctx = UIGraphicsGetCurrentContext();
UIGraphicsPushContext(ctx);
[self.layer renderInContext:ctx];
UIGraphicsEndImageContext();
UIGraphicsPopContext();
size.width = CGRectGetWidth(rect);
size.height = CGRectGetMinY(rect) + [(CMText *)[m_nodes lastObject] frame].end.y;
return size;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment