Skip to content

Instantly share code, notes, and snippets.

@kmdarshan
Created August 24, 2015 06:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmdarshan/f74441b45288f99ff629 to your computer and use it in GitHub Desktop.
Save kmdarshan/f74441b45288f99ff629 to your computer and use it in GitHub Desktop.
self.button.titleLabel.numberOfLines = 0;
// be careful, don't set this. If you set this, content insets won't work
// for title.
// self.button.titleLabel.textAlignment = NSTextAlignmentLeft;
[self.button.titleLabel sizeToFit];
[self.button setAttributedTitle:mutableAttributedString forState:UIControlStateNormal];
self.button.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
self.button.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter;
UIImage *icon = [[UIImage imageNamed:@"btn"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.button setImage:icon forState:UIControlStateNormal];
// setting the insets
self.button.contentEdgeInsets = UIEdgeInsetsMake(0, 100.0f, 0, 0);
self.button.titleEdgeInsets = UIEdgeInsetsMake(0, 50.0f, 0, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment