Skip to content

Instantly share code, notes, and snippets.

@zeedark
Created January 19, 2012 09:55
Show Gist options
  • Save zeedark/1639124 to your computer and use it in GitHub Desktop.
Save zeedark/1639124 to your computer and use it in GitHub Desktop.
Resize a UIButton according to its title's length.
// Resize a UIButton according to its title's length.
CGSize stringSize = [self.myButton.titleLabel.text sizeWithFont:self.myButton.titleLabel.font];
CGRect frame = self.myButton.frame;
frame.size.width = stringSize.width;
[self.myButton setFrame:frame];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment