Draw Shadow Only * Around * UIView that contains transparency

Question: I am struggling. I have been looking for SO for a long time, but could not find an answer.

I have UIViewone that contains an alpha value 0.5, means - it transparent.

If I use regular code for UIViewshadowing -

 class func applyShadow(view : UIView)
    {
        view.layer.shadowColor = UIColor.blackColor().colorWithAlphaComponent(0.15).CGColor
        view.layer.shadowOpacity = 1
        view.layer.shadowOffset = CGSizeMake(0, 0.5)
        view.layer.shadowRadius = 1.3
        view.layer.masksToBounds = false
        view.layer.shouldRasterize = true
        view.layer.rasterizationScale = UIScreen.mainScreen().scale

    }

My fill is UIViewalso obscured.

How to draw a shadow only along the path of the "border" of mine UIView, excluding filling UIView?

+4
source share

Source: https://habr.com/ru/post/1659363/


All Articles