I'm almost sure this question has been asked before, but I searched for almost an hour and didn't find anything
This is my code:
textField.font = UIFont.systemFont(ofSize: 12.0)
textField.layer.borderWidth = 0.9
textField.placeholder = "border is 0.9 clip is false"
textField.layer.borderColor = UIColor.black.cgColor
textField.borderStyle = UITextBorderStyle.roundedRect
textField.returnKeyType = UIReturnKeyType.done
Doesn't matter if set textField.clipsToBounds
to true
or false
, the borders won't be rounded. However if I change the background color, it will fill it as it has a rounded border, see the image below.
if you zoom in, you'll see that the it doesn't fill the corners completely
If I set textField.layer.borderWidth = 0.1
then I would have a nice roundedRect, but they border would then have to be a thin line. See the image below:
again setting clipToBounds = true
won't make any difference.
EDIT:
So the answer is to do textField.layer.cornerRadius = 5
. But then I wonder what is the UITextBorderStyle.roundedRect
doing then?!