I have implemented a UIView with rounded rect only at the top left and top right corners using UIBezierPath. But after that when i add a shadow to the view, it doesn't show the shadow. If i just remove the bezier rounded corners, then the shadow works perfectly fine. But now only the rounded corners appear without any shadow. Here's my code
override func drawRect(rect: CGRect)
{
super.drawRect(rect)
let shapeLayer : CAShapeLayer = CAShapeLayer(layer: centerView.layer)
shapeLayer.path = UIBezierPath(roundedRect: centerView.layer.bounds, byRoundingCorners: UIRectCorner.TopRight|UIRectCorner.TopLeft, cornerRadii: CGSizeMake(15,15)).CGPath
centerView.layer.mask = shapeLayer
centerView.layer.masksToBounds = false
centerView.layer.shadowOffset = CGSizeMake(0,-2)
centerView.layer.shadowRadius = 0.5
centerView.layer.shadowOpacity = 0.7
centerView.layer.shadowColor = UIColor(red: 0.867, green: 0.867, blue: 0.867, alpha: 1).CGColor
centerView.layer.shadowPath = UIBezierPath(roundedRect: centerView.layer.bounds, byRoundingCorners: UIRectCorner.TopRight|UIRectCorner.TopLeft, cornerRadii: CGSizeMake(15,15)).CGPath
}
Here i override the drawRect of a UITableViewCell and centerView is a subview of it. Also i tried subclassing UIView for centerView, that too doesn't seem to work.
Does the mask property and maskToBounds property of a CALayer conflict with each other ?