Skip to content

Instantly share code, notes, and snippets.

@timothy1ee
Created January 28, 2014 05:21
Show Gist options
  • Save timothy1ee/8662658 to your computer and use it in GitHub Desktop.
Save timothy1ee/8662658 to your computer and use it in GitHub Desktop.
// adjust the textView width base on screen size and orientation
// the only constant width in the cells is the checkbox (64)
CGRect screenRect = [[UIScreen mainScreen] bounds];
CGFloat width = [self isPortraitOrientation] ? screenRect.size.width : screenRect.size.height;
width -= 64;
CGRect textRect = [textView.text boundingRectWithSize:CGSizeMake(width, MAXFLOAT)
options:NSStringDrawingUsesLineFragmentOrigin
attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:17]}
context:nil];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment