Skip to content

Instantly share code, notes, and snippets.

@harmittaa
Created October 5, 2017 06:18
Show Gist options
  • Save harmittaa/a5d4ef1cf00cd94e79be1d3b8490021c to your computer and use it in GitHub Desktop.
Save harmittaa/a5d4ef1cf00cd94e79be1d3b8490021c to your computer and use it in GitHub Desktop.

Revisions

  1. harmittaa created this gist Oct 5, 2017.
    12 changes: 12 additions & 0 deletions ButtonWithImage.swift
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    import UIKit

    class ButtonWithImage: UIButton {

    override func layoutSubviews() {
    super.layoutSubviews()
    if imageView != nil {
    imageEdgeInsets = UIEdgeInsets(top: 5, left: (bounds.width - 35), bottom: 5, right: 5)
    titleEdgeInsets = UIEdgeInsets(top: 0, left: 0, bottom: 0, right: (imageView?.frame.width)!)
    }
    }
    }