iOS rounded UITextField with shadow

后端 未结 6 1744
猫巷女王i
猫巷女王i 2021-02-08 01:24

I would like to add a shadow effect to my UITextField currently what I\'m achieving is this:
As you can see the shadow is not rounded in the corners. My code:



        
6条回答
  •  醉话见心
    2021-02-08 01:51

    You can use this extension

    extension ViewController {
        func setShadow(_ view: UIView) {
            view.layer.masksToBounds = false;
            view.layer.shadowRadius  = 3.0;
            view.layer.shadowColor   = UIColor.black.cgColor;
            view.layer.shadowOffset  = CGSize(width: 2.0, height: 4.0);
            view.layer.shadowOpacity = 1.0;
        }
    }
    

提交回复
热议问题