Skip to content

Instantly share code, notes, and snippets.

@Laeyoung
Forked from lawreyios/uitextfieldwithpadding
Last active July 20, 2018 14:02
Show Gist options
  • Save Laeyoung/717002e14dbd97b810569be4ffbf6ed0 to your computer and use it in GitHub Desktop.
Save Laeyoung/717002e14dbd97b810569be4ffbf6ed0 to your computer and use it in GitHub Desktop.
Add padding to UITextField - Swift 3.0
class CustomSearchTextField: UITextField {
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func textRect(forBounds bounds: CGRect) -> CGRect {
return UIEdgeInsetsInsetRect(bounds, UIEdgeInsetsMake(0, 15, 0, 15))
}
override func editingRect(forBounds bounds: CGRect) -> CGRect {
return UIEdgeInsetsInsetRect(bounds, UIEdgeInsetsMake(0, 15, 0, 15))
}
override func placeholderRect(forBounds bounds: CGRect) -> CGRect {
return UIEdgeInsetsInsetRect(bounds, UIEdgeInsetsMake(0, 15, 0, 15))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment