Skip to content

Instantly share code, notes, and snippets.

@sunnyleeyun
Last active June 11, 2019 12:19
Show Gist options
  • Save sunnyleeyun/6bf8f11d50789f741c99f2ea858acffd to your computer and use it in GitHub Desktop.
Save sunnyleeyun/6bf8f11d50789f741c99f2ea858acffd to your computer and use it in GitHub Desktop.
import Foundation
class UITextFieldPadding : UITextField {
let padding = UIEdgeInsets(top: 0, left: 10, bottom: 0, right: 10)
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
override func textRect(forBounds bounds: CGRect) -> CGRect {
return bounds.inset(by: padding)
}
override func placeholderRect(forBounds bounds: CGRect) -> CGRect {
return bounds.inset(by: padding)
}
override 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