Skip to content

Instantly share code, notes, and snippets.

@bugrym
Created February 18, 2020 12:45
Show Gist options
  • Save bugrym/cee810e3a69373bd638170ff7aca0114 to your computer and use it in GitHub Desktop.
Save bugrym/cee810e3a69373bd638170ff7aca0114 to your computer and use it in GitHub Desktop.
UIImageView with a convenience initializer that allows us to include the insets
extension UIImageView {
convenience init(named name: String, top: CGFloat, left:
CGFloat, bottom: CGFloat, right: CGFloat) {
let insets = UIEdgeInsetsMake(top, left, bottom, right) let originalImage = UIImage(named: name)
let insetImage = originalImage?.withAlignmentRectInsets(insets) self.init(image: insetImage)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment