UIButton bottom shadow

后端 未结 11 1167
-上瘾入骨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 14:47

    in swift 2.0 add shadow uiview (uibutton) with code before class declaration or in swift file functions:

    extension UIView {
    
        func addShadowView(width:CGFloat=0.2, height:CGFloat=0.2, Opacidade:Float=0.7, maskToBounds:Bool=false, radius:CGFloat=0.5){
             self.layer.shadowColor = UIColor.blackColor().CGColor
             self.layer.shadowOffset = CGSize(width: width, height: height)
             self.layer.shadowRadius = radius
             self.layer.shadowOpacity = Opacidade
             self.layer.masksToBounds = maskToBounds
        }
    
    }
    

    in viewdidload add this code

    button.addShadowView()
    

提交回复
热议问题