Created
July 19, 2017 09:40
-
-
Save 29satnam/5e88bc9203b04b68296d23b85a14efe1 to your computer and use it in GitHub Desktop.
This is how you can set only Bottom Border to UITextField using Swift 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BottomBorderTF: UITextField { | |
var bottomBorder = UIView() | |
override func awakeFromNib() { | |
//MARK: Setup Bottom-Border | |
self.translatesAutoresizingMaskIntoConstraints = false | |
bottomBorder = UIView.init(frame: CGRect(x: 0, y: 0, width: 0, height: 0)) | |
bottomBorder.backgroundColor = UIColor.orange | |
bottomBorder.translatesAutoresizingMaskIntoConstraints = false | |
addSubview(bottomBorder) | |
//Mark: Setup Anchors | |
bottomBorder.bottomAnchor.constraint(equalTo: bottomAnchor).isActive = true | |
bottomBorder.leftAnchor.constraint(equalTo: leftAnchor).isActive = true | |
bottomBorder.rightAnchor.constraint(equalTo: rightAnchor).isActive = true | |
bottomBorder.heightAnchor.constraint(equalToConstant: 1).isActive = true // Set Border-Strength | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment