UIButton bottom shadow

后端 未结 11 1155
-上瘾入骨i
-上瘾入骨i 2020-12-12 14:14

I have a UIButton which is very similar to the standard iOS keyboard alphabet button.

I am not sure how to create a shadow only for the bottom layer li

11条回答
  •  旧巷少年郎
    2020-12-12 15:05

    Put this method into your UIView extension and play with offset value

    func drawShadow(shadowColor: UIColor = UIColor.black, opacity: Float =
    0.3, offset: CGSize, radius: CGFloat = 5, shouldRasterize : Bool = false) {
            self.layer.shadowColor = shadowColor.cgColor
            self.layer.shadowOpacity = opacity
            self.layer.shadowOffset = offset
            self.layer.shadowRadius = radius
            self.layer.shouldRasterize = shouldRasterize
        }
    

提交回复
热议问题