I create a custom view that I want to hide and add a shadow to it.
disguise:
let p = UIBezierPath() p.moveToPoint(CGPointMake(20, 20)) p.addLineToPoint(CGPointMake(100, 20)) p.addLineToPoint(CGPointMake(100, 50)) p.addLineToPoint(CGPointMake(110, 55)) p.addLineToPoint(CGPointMake(100, 60)) p.addLineToPoint(CGPointMake(100, 100)) p.addLineToPoint(CGPointMake(20, 100)) p.closePath() let s = CAShapeLayer() s.frame = layer.bounds s.path = p.CGPath s.fillColor = UIColor.greenColor().CGColor layer.mask = s
disguise works, now I want to add a shadow. but does not work.
I tried adding a shadow to the main layer and nothing happens.
layer.shadowColor = UIColor.yellowColor().CGColor layer.shadowRadius = 10 layer.shadowOpacity = 0.9 layer.shadowOffset = CGSizeZero
I tried to add it to the mask layer, and I got the main view, a masked shadow.
s.shadowColor = UIColor.yellowColor().CGColor s.shadowRadius = 10 s.shadowOpacity = 0.9 s.shadowOffset = CGSizeZero
Any suggestions for adding this yellow shadow to the hidden view?
thanks
source share