view.Layer.CornerRadius not working on UIScrollView subView of UIView Swift 3 iOS
<p>I want the view to have rounded corners so I added</p>

<pre><code>cardView.layer.cornerRadius = 5
</code></pre>

<p>But the subView of cardView, i.e. sViewListing which is a <code>UIScrollView</code> just doesn't seem to get effected by it. </p>

<p>I just want the topRight &amp; topLeft <code>cornerRadius</code> of the <code>UIScrollView</code> to be set to 5 so I tried using <code>UIBezierPath</code> to mask it too but it still doesn't seem to work. </p>

<p>The following is what i tried:</p>

<pre><code>import UIKit

class TableViewCell: UITableViewCell {

@IBOutlet var cardView: UIView!
@IBOutlet var sViewListing: UIScrollView!
@IBOutlet var bookTitleListing: UILabel!
@IBOutlet var ratingListing: UIImageView!
@IBOutlet var locationListing: UILabel!
@IBOutlet var priceListing: UILabel!

override func awakeFromNib() {
    super.awakeFromNib()

    let path = UIBezierPath(roundedRect:sViewListing.bounds,
                            byRoundingCorners:[.topRight, .topLeft],
                            cornerRadii: CGSize(width: 5, height:  5))

    let maskLayer = CAShapeLayer()

    maskLayer.path = path.cgPath
    sViewListing.layer.mask = maskLayer
    cardView.backgroundColor = UIColor.white
    cardView.layer.cornerRadius = 5
    cardView.clipsToBounds = true
    cardView.layer.masksToBounds = false
    cardView.layer.shadowColor = UIColor.black.withAlphaComponent(0.3).cgColor
    cardView.layer.shadowOffset = CGSize(width: 0, height: 0)
    cardView.layer.shadowOpacity = 0.8

    }

}
</code></pre>

<p>What can I do to fix it? </p>