Shadow not showing when background color is clear color

后端 未结 3 963
悲&欢浪女
悲&欢浪女 2021-01-01 09:33

I\'ve created an uiview in my xib with background color as clear color. When I apply the shadow on the layer of the view, the shadow is not appearing. But when i set the bac

3条回答
  •  隐瞒了意图╮
    2021-01-01 10:21

    Equivalent to @Rok Jark's answer in Swift 4:

    self.layer.shadowColor = UIColor(white: 0.5, alpha: 1).cgColor
    self.layer.shadowRadius = 4.0
    self.layer.shadowPath = CGPath.init(rect: CGRect.init(x: 0, y: 0, width: 50, height: 50), transform: nil)
    self.layer.shadowOpacity = 1.0;
    self.layer.shadowOffset = CGSize(width: 1, height: 1)
    

提交回复
热议问题