Andrey_ZoZ

MakeShadow

Jun 21st, 2021
865
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. extension UIView {
  2. func dropShadow(color: UIColor, opacity: Float = 0.3, offSet: CGSize, radius: CGFloat = 10, scale: Bool = true) {
  3.     layer.masksToBounds = false
  4.     layer.shadowColor = color.cgColor
  5.     layer.shadowOpacity = opacity
  6.     layer.shadowOffset = offSet
  7.     layer.shadowRadius = radius
  8.  
  9.     layer.shadowPath = UIBezierPath(rect: self.bounds).cgPath
  10.     layer.shouldRasterize = true
  11.     layer.rasterizationScale = scale ? UIScreen.main.scale : 1
  12.   }
  13. }
RAW Paste Data