Skip to content

Instantly share code, notes, and snippets.

@janeshsutharios
Created April 10, 2021 05:59
Show Gist options
  • Save janeshsutharios/1a60b0510871277d5a5841181c75aaea to your computer and use it in GitHub Desktop.
Save janeshsutharios/1a60b0510871277d5a5841181c75aaea to your computer and use it in GitHub Desktop.
PaddingUItextField.swift
class PaddingTextField: UITextField {
let padding = UIEdgeInsets(top: 4, left: 8, bottom: 4, right: 8)
override open func textRect(forBounds bounds: CGRect) -> CGRect {
return bounds.inset(by: padding)
}
override open func placeholderRect(forBounds bounds: CGRect) -> CGRect {
return bounds.inset(by: padding)
}
override open func editingRect(forBounds bounds: CGRect) -> CGRect {
return bounds.inset(by: padding)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment