UIView with shadow, rounded corners and custom drawRect

前端 未结 16 1405
南旧
南旧 2020-12-02 05:22

I have to create a custom UIView that will have round corners, a border, a shadow and its drawRect() method is overridden to provide custom drawing

16条回答
  •  借酒劲吻你
    2020-12-02 05:52

    you can use this function for your all views.

        extension UIView{
    
        func radiusAndBorder(radius:CGFloat, color:UIColor = UIColor.clear) -> UIView{
            var rounfView:UIView = self
            rounfView.layer.cornerRadius = CGFloat(radius)
            rounfView.layer.borderWidth = 1
            rounfView.layer.borderColor = color.cgColor
            rounfView.clipsToBounds = true
            return rounfView
        }
    }
    

提交回复
热议问题