Skip to content

Instantly share code, notes, and snippets.

@sharat
Created October 6, 2017 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sharat/60861c51d6bb4b84e10d2f6827e72c7e to your computer and use it in GitHub Desktop.
Save sharat/60861c51d6bb4b84e10d2f6827e72c7e to your computer and use it in GitHub Desktop.
extension UITextField {
func useUnderline() -> Void {
let border = CALayer()
let borderWidth = CGFloat(2.0) // Border Width
border.borderColor = UIColor.red.cgColor
border.frame = CGRect(origin: CGPoint(x: 0,y :self.frame.size.height - borderWidth), size: CGSize(width: self.frame.size.width, height: self.frame.size.height))
border.borderWidth = borderWidth
self.layer.addSublayer(border)
self.layer.masksToBounds = true
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment