CircleBar icon indicating copy to clipboard operation
CircleBar copied to clipboard

Not able show shadow effect.

Open VDPurohit opened this issue 5 years ago • 4 comments

Shadow effect not showing.I added shadow radius and shadow color viewwillAppear of SHCircleBarController using below code.

tabBar.layer.shadowOffset = CGSize(width: 0, height: 0)
tabBar.layer.shadowRadius = 2
tabBar.layer.shadowColor = UIColor.black.cgColor
tabBar.layer.shadowOpacity = 0.3

(https://stackoverflow.com/questions/37338288/ios-getting-desired-shadow-above-uitabbar) but not working.

Please help me to add shadow in tabbar.

Thanks, Vivek

VDPurohit avatar Sep 10 '19 07:09 VDPurohit

I'm unable to change layer properties too.

developerawais1 avatar Dec 17 '19 10:12 developerawais1

Did anyone ever solve this?

Brandon-316 avatar Jul 20 '20 18:07 Brandon-316

anyone been able to apply shadow yet ? @perteadrian @perteraul @bcylin

sseifallah avatar Aug 05 '20 14:08 sseifallah

Add the following lines under draw() function in SHCircleBar class: override func draw(_ rect: CGRect) { ....

    let shadowSubLayer = createShadowLayer()
    shadowSubLayer.accessibilityHint = "shadow"
    shadowSubLayer.insertSublayer(mask, at: 0)
    
    self.layer.sublayers?.filter({$0.accessibilityHint == "shadow"}).forEach({$0.removeFromSuperlayer()})
    self.layer.insertSublayer(shadowSubLayer, at: 0)
    self.backgroundColor = .clear
}

use the following function to create shadow: func createShadowLayer() -> CALayer { let shadowLayer = CALayer() shadowLayer.shadowColor = UIColor.black.cgColor shadowLayer.shadowOffset = CGSize.zero shadowLayer.shadowRadius = 2.0 shadowLayer.shadowOpacity = 0.2 shadowLayer.backgroundColor = UIColor.clear.cgColor return shadowLayer }

hisham93 avatar May 15 '21 02:05 hisham93