Skip to content

Instantly share code, notes, and snippets.

@austintaylor
Created October 31, 2013 16:34
Show Gist options
  • Save austintaylor/7252793 to your computer and use it in GitHub Desktop.
Save austintaylor/7252793 to your computer and use it in GitHub Desktop.
- (CGFloat)cellWidthForStyle:(UITableViewStyle)style accessoryType:(UITableViewCellAccessoryType)accessoryType {
CGFloat width = self.view.frame.size.width;
CGFloat accessoryWidth;
CGFloat margin;
if (IOS7) {
if (accessoryType == UITableViewCellAccessoryDisclosureIndicator) {
accessoryWidth = 33;
}
} else {
if (accessoryType == UITableViewCellAccessoryDisclosureIndicator) {
accessoryWidth = 20;
}
if (width > 20) {
if (width < 400) {
margin = 10;
} else {
margin = MAX(31, MIN(45, width*0.06));
}
} else {
margin = width - 10;
}
}
return width - (style == UITableViewStyleGrouped ? margin * 2 : 0) - accessoryWidth;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment