Question: I have cell's imageView shadow customization:

```
override func layoutSubviews() {
    moviePosterImageView.layer.shadowOffset = .zero
    moviePosterImageView.layer.shadowColor = UIColor.black.cgColor
    moviePosterImageView.layer.shadowRadius = 5
    moviePosterImageView.layer.shadowOpacity = 1
    moviePosterImageView.layer.masksToBounds = false
    moviePosterImageView.layer.shadowPath = UIBezierPath(rect: moviePosterImageView.bounds).cgPath
}

```

But it breaks imageView sizes and constraints. Without shadow it works pretty good.

[![enter image description here](https://i.stack.imgur.com/LR0Mr.png)](https://i.stack.imgur.com/LR0Mr.png)

Answer: 
> 
> But it breaks imageView sizes and constraints.
> 
> 
> 

Yes, because you forgot to start by saying

```
override func layoutSubviews() {
    super.layoutSubviews() // important

```

Since autolayout happens *in* `layoutSubviews`, if you don’t call `super` you prevent it from operating.
Use This Code in another swift File and set shadow in story board or xib easily

```
extension UIView {

@IBInspectable
var cornerRadius: CGFloat {
    get {
        return layer.cornerRadius
    }
    set {
        layer.cornerRadius = newValue
    }
}

@IBInspectable
var borderWidth: CGFloat {
    get {
        return layer.borderWidth
    }
    set {
        layer.borderWidth = newValue
    }
}

@IBInspectable
var borderColor: UIColor? {
    get {
        if let color = layer.borderColor {
            return UIColor(cgColor: color)
        }
        return nil
    }
    set {
        if let color = newValue {
            layer.borderColor = color.cgColor
        } else {
            layer.borderColor = nil
        }
    }
}

@IBInspectable
var shadowRadius: CGFloat {
    get {
        return layer.shadowRadius
    }
    set {
        layer.shadowRadius = newValue
    }
}

@IBInspectable
var shadowOpacity: Float {
    get {
        return layer.shadowOpacity
    }
    set {
        layer.shadowOpacity = newValue
    }
}

@IBInspectable
var shadowOffset: CGSize {
    get {
        return layer.shadowOffset
    }
    set {
        layer.shadowOffset = newValue
    }
}

@IBInspectable
var shadowColor: UIColor? {
    get {
        if let color = layer.shadowColor {
            return UIColor(cgColor: color)
        }
        return nil
    }
    set {
        if let color = newValue {
            layer.shadowColor = color.cgColor
        } else {
            layer.shadowColor = nil
        }
    }
  }
}

```