Weird behavior with UIView / Shadow while transition the constraint (Pictures inside)

59 Views Asked by At

I have something like a SlideUp View with a TableView inside. I am changing the constraint of my SlideUp View to increase the width. However, this is the result on sliding it up or down:

The result on slide down:

i

The result on slide up:

enter image description here

When the transition is finished, everything is normal:

enter image description here

This is the Code for my shadowed ViewContainer inside the TableView:

import UIKit

@IBDesignable class ShadowedView: UIView {

@IBInspectable var shadowed: Bool = true {
   didSet {
      setNeedsLayout()
   }
}
@IBInspectable var cornerRadius: CGFloat = 0.0 {
   didSet {
      setNeedsLayout()
   }
}
@IBInspectable var shadowRadius: CGFloat = 0.0 {
   didSet {
      setNeedsLayout()
   }
}

override func layoutSubviews () {
    super.layoutSubviews()
    layer.shadowColor = UIColor.black.cgColor
    layer.shadowOpacity = 1
    layer.shadowRadius = shadowRadius
    layer.shadowOffset = CGSize(width: 0, height: 0)
    layer.shadowPath = UIBezierPath(roundedRect: self.bounds, cornerRadius: cornerRadius).cgPath
    layer.shouldRasterize = true
    layer.rasterizationScale = UIScreen.main.scale
}

}

Where is this behavior coming from and how can I prevent it?

0

There are 0 best solutions below