I am facing a strange issue when I try to apply rounded corners and shadow to my UITableView
with dynamic content, which changes height as per the data (number of cells).
Here is screen recording of the jerky effect on scrolling.
My motive is to add shadow and corner radius to the dynamic table view.
When I add the corner radius it works fine, but when I try to add the shadow it doesn't show up. So I found a solution here saying that we need to set
self.tableView.clipsToBounds = false
self.tableView.layer.masksToBounds = false
However, after setting it I am getting the above jerky effect and the corner radius is no longer visible.
I tried other (proposed) solutions like adding a custom view on runtime with respect to tableview frame, but that creates a static height view and hence disabling the interactivity with the superview for that area.
Here is my code:
searchResultTblView.layer.cornerRadius = 10
searchResultTblView.layer.maskedCorners = [.layerMinXMaxYCorner , .layerMaxXMaxYCorner]
searchResultTblView.keyboardDismissMode = .onDrag
searchResultTblView.layer.shadowColor = UIColor.gray.cgColor
searchResultTblView.layer.shadowOpacity = 0.6
searchResultTblView.layer.shadowRadius = 5
searchResultTblView.tableFooterView = UIView.init(frame: CGRect.zero)
searchResultTblView.separatorInset = .zero
searchResultTblView.clipsToBounds = false
searchResultTblView.layer.masksToBounds = false
I know there's probably a better way to set both shadow and corner radius on the table view. However, I am currently unable to achieve it.