Skip to content

Instantly share code, notes, and snippets.

@oldtrafford91
Created September 15, 2018 11:07
Show Gist options
  • Save oldtrafford91/bb9f5916c5a29d0d618c8166bede4a07 to your computer and use it in GitHub Desktop.
Save oldtrafford91/bb9f5916c5a29d0d618c8166bede4a07 to your computer and use it in GitHub Desktop.
Change UIButton spacing between title and image with out affect intrinsicContentSize
extension UIButton {
func changeButtonTitleAndImageSpacing(spacing: CGFloat) {
let insetAmount = spacing / 2
imageEdgeInsets = UIEdgeInsets(top: 0, left: -insetAmount, bottom: 0, right: insetAmount)
titleEdgeInsets = UIEdgeInsets(top: 0, left: insetAmount, bottom: 0, right: -insetAmount)
contentEdgeInsets = UIEdgeInsets(top: 0, left: insetAmount, bottom: 0, right: insetAmount)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment