Thursday, March 2, 2017

Swift how to have a Textfield that is having only bottom border





Below can be written on file say for e.g. UITextFieldExtension

extension UITextField{

func useUnderline() {

self.borderStyle = UITextBorderStyle.none

self.backgroundColor = UIColor.clear

let width = 1.0

let borderLine = UIView()

borderLine.frame = CGRect(x: 0, y: Double(self.frame.height) - width, width: Double(self.frame.width), height: width)

borderLine.backgroundColor = UIColor.lightGray

self.addSubview(borderLine)

}

at the time of calling , it can be called like below


 tfSample.useUnderline()

references:

No comments:

Post a Comment