Skip to content

Instantly share code, notes, and snippets.

@vinczebalazs
Created January 25, 2020 22:32
Show Gist options
  • Save vinczebalazs/60d0b08283d87c7e8c4c08ff72ae6148 to your computer and use it in GitHub Desktop.
Save vinczebalazs/60d0b08283d87c7e8c4c08ff72ae6148 to your computer and use it in GitHub Desktop.
UIButton+Padding
extension CGSize {
func addingPadding(width: CGFloat, height: CGFloat) -> CGSize {
CGSize(width: self.width + width, height: self.height + height)
}
}
// Usage:
class PaddedButton: UIButton {
override var intrinsicContentSize: CGSize {
super.intrinsicContentSize.addingPadding(width: 60, height: 20)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment