Created
March 13, 2020 07:49
-
-
Save illescasDaniel/8f8212eb75641627b0c1d69fdbc8932b to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| class RoundImageView: UIImageView { | |
| override func layoutSubviews() { | |
| super.layoutSubviews() | |
| imageView.layer.shadowColor = UIColor.black.cgColor | |
| imageView.layer.shadowOpacity = 1 | |
| let shadowRadius: CGFloat = 8 | |
| imageView.layer.shadowRadius = shadowRadius | |
| imageView.layer.shadowOffset = .zero | |
| imageView.frame = imageView.frame.inset(by: UIEdgeInsets(top: shadowRadius, left: shadowRadius, bottom: shadowRadius, right: shadowRadius)) | |
| imageView.layer.cornerRadius = self.frame.width / 2// asssuming the aspect ratio is 1:1 | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment