hov bibid
hov bibid

Reputation: 21

UITextfield shadow

I want to add shadow to my UITextfield I tried code below, shadows work fine, but there is one thing, it is also set on the text inside my UITextfield any solutions ?

  passwordTextField.layer.masksToBounds = false
  passwordTextField.layer.shadowRadius = 4.0
  passwordTextField.layer.shadowColor = UIColor.black.cgColor
  passwordTextField.layer.shadowOffset = CGSize(width: 1.0, height: 1.0)
  passwordTextField.layer.shadowOpacity = 1.0

picture for better understanding: enter image description here

as you can see on the picture above, shadow is also set on textfield, how can I only set shadow to corner?

Upvotes: 1

Views: 311

Answers (1)

valosip
valosip

Reputation: 3402

You should be able to just set the textfield background color to white and it will remove the text shadow.

passwordTextField.backgroundColor = .white // or whatever color you need

Upvotes: 3

Related Questions