Skip to content

Instantly share code, notes, and snippets.

@illescasDaniel
Created March 13, 2020 07:49
Show Gist options
  • Select an option

  • Save illescasDaniel/8f8212eb75641627b0c1d69fdbc8932b to your computer and use it in GitHub Desktop.

Select an option

Save illescasDaniel/8f8212eb75641627b0c1d69fdbc8932b to your computer and use it in GitHub Desktop.
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