Nikita Zernov
Nikita Zernov

Reputation: 5645

iOS: Moving bottom border of UITextField down

I added bottom border to UITextField this way:

let bottomLine = CALayer()
bottomLine.frame = CGRectMake(0.0, self.frame.height, self.frame.width, CGFloat(borderWidth))
bottomLine.backgroundColor = borderColor.CGColor
self.borderStyle = UITextBorderStyle.None
self.layer.addSublayer(bottomLine)

And I am getting this:

enter image description here

I would like move border down. To do this I am setting border frame this way:

bottomLine.frame = CGRectMake(0.0, self.frame.height + 5, self.frame.width, CGFloat(borderWidth))

Here I am increasing it by 5px. But it moves beyond the text field's frame. But I cannot adjust UITextField's height:

enter image description here

If I am setting it programmatically, application hangs on refreshing designables (I am using IBDesignable subclass of UITextField).

Upvotes: 0

Views: 235

Answers (1)

kirti Chavda
kirti Chavda

Reputation: 3015

select show attribute inspector then change border style

see below imageenter image description here

Upvotes: 1

Related Questions