Created
February 18, 2020 12:45
-
-
Save bugrym/cee810e3a69373bd638170ff7aca0114 to your computer and use it in GitHub Desktop.
UIImageView with a convenience initializer that allows us to include the insets
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 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