Created
September 15, 2018 11:07
-
-
Save oldtrafford91/bb9f5916c5a29d0d618c8166bede4a07 to your computer and use it in GitHub Desktop.
Change UIButton spacing between title and image with out affect intrinsicContentSize
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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